(四十三)java版spring cloud+spring boot+redis多租户社交电子商务平台-eureka集群整合config配置中心...

电子商务平台源码请加企鹅求求:三五三六二四七二五九。加入依赖


   
   
      org.springframework.boot
      spring-boot-starter-actuator
   

   
   
      org.springframework.boot
      spring-boot-starter-security
   

   
   
      org.springframework.cloud
      spring-cloud-config-server
   
   
      org.springframework.cloud
      spring-cloud-starter-eureka
   



application.yml

server:
  port: 8881

spring:
  application:
    name: tms-config
  cloud:
    config:
      server:
        git:
          uri: 仓库地址
          searchPaths: 目录
          username: 用户名
          password: 密码
      label: master

eureka:
  instance:
    prefer-ip-address: true
    lease-renewal-interval-in-seconds: 30
    lease-expiration-duration-in-seconds: 90
    metadata-map:
      name: tms-config-metadata-map-name
  client:
    serviceUrl:
      defaultZone: http://admin:[email protected]:8761/eureka/, http://admin:[email protected]:8762/eureka/
    # 抓取服务列表时间间隔
    registry-fetch-interval-seconds: 30

endpoints:
  sensitive: false
  shutdown:
    enabled: true
    sensitive: true

security:
  user:
    name: admin
    password: admin
    role: SUPERUSER

management:
  context-path: /tms-config
  security:
    roles: SUPERUSER #角色

# 日志
logging:
  file: logs/logger.log
  level:
    com.netflix: DEBUG
    org.springframework.web: DEBUG
    org.springframework.security: INFO
复制代码

启动项

@SpringBootApplication
@EnableConfigServer
@EnableEurekaClient
public class TmsConfigApplication {

   public static void main(String[] args) {
      SpringApplication.run(TmsConfigApplication.class, args);
   }
}
复制代码

调用者配置 ,注意这里要用此配置文件名 bootstrap.yml

spring:
  application:
    name: tms-client
  cloud:
    config:
      label: master
      profile: dev
      username: admin
      password: admin
      discovery:
        enabled: true
        service-id: tms-config

eureka:
  client:
    serviceUrl:
      defaultZone: http://admin:[email protected]:8761/eureka/, http://admin:[email protected]:8762/eureka/
复制代码

读取配置文件内容


@RestController
public class TestController {

    @Value("${apuserName}")
    private String apuserName;

    @GetMapping(value = "/hello")
    public String hello() {
        return apuserName;
    }
}
复制代码

转载于:https://juejin.im/post/5cf78ba1f265da1b6d4013c0

你可能感兴趣的:((四十三)java版spring cloud+spring boot+redis多租户社交电子商务平台-eureka集群整合config配置中心...)