(11)springcloud配置中心--客户端
以hello-spring-cloud-web-admin-feign为例,
1.在pom.xml中增加依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
2.在application.yml原来配置删掉,加如下配置,
spring:
cloud:
config:
uri: http://localhost:8888
name: web-admin-feign
label: master
profile: dev
3.启动WebAdminFeignApplication项目,在启动日志中可以看到 端口号是8765
4.在hello-spring-cloud新建web-admin-feign-prod.yml
spring:
application:
name: hello-spring-cloud-web-admin-feign
thymeleaf:
cache: false
mode: LEGACYHTML5
encoding: UTF-8
servlet:
content-type: text/html
server:
port: 8766
feign:
hystrix:
enabled: true
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
将配置文件上传到git
5.将第2步的application.yml配置文件中的profile:dev改成 profile:prod
spring:
cloud:
config:
uri: http://localhost:8888
name: web-admin-feign
label: master
profile: prod
再次启动WebAdminFeignApplication项目,在启动日志中可以看到 端口号是8766
还没有评论,来说两句吧...