compile(‘org.springframework.cloud:spring-cloud-config-server‘)
compile(‘org.springframework.cloud:spring-cloud-starter-netflix-eureka-client‘)
1 spring: 2 cloud: 3 config: 4 server: 5 git: 6 uri: https://gitee.com/JinYitao/config-server.git #远程仓库地址 7 search-paths: local #搜索配置文件的路径 8 clone-on-start: true #开始时克隆 9 username: username #远程仓库用户名与密码 10 password: password 11 enabled: true #启用远程配置 12 application: 13 name: qnbbs-config-server 14 server: 15 port: 8880 16 eureka: 17 instance: 18 prefer-ip-address: true 19 ip-address: xx.xxx.xx.xx #部署到linux上时一定要加上本机ip,window系统开发可以不设置 20 client: 21 service-url: 22 defaultZone: http://eureka1:8761/eureka/,http://eureka2:8761/eureka/,http://eureka3:8761/eureka/ 23 #注册注册中心到集群中
search-paths
图例:
启动类添加
@EnableDiscoveryClient
@EnableConfigServer
compile(‘org.springframework.cloud:spring-cloud-starter-netflix-eureka-client‘) compile(‘org.springframework.cloud:spring-cloud-starter-config‘) //客户端依赖 ? //访问配置失败重试 compile(‘org.springframework.boot:spring-boot-starter-aop‘) compile(‘org.springframework.retry:spring-retry‘)
eureka: client: service-url: defaultZone: http://eureka1/eureka/ spring: application: name: qnbbs-provider cloud: config: discovery: enabled: true #启动发现服务 service-id: qnbbs-config-server #与注册中心中的 spring.application.name 值保持一致 fail-fast: true #Flag to indicate that failure to connect to the server is fatal (default false). retry: initial-interval: 15000 #最初的重试时间间隔,以毫秒为单位 max-attempts: 5 #最大数量的尝试
原文:https://www.cnblogs.com/bqzz/p/10369605.html