您现在的位置是:首页 > 文章详情

java B2B2C Springcloud电子商务平台源码-eureka集群整合config配置中心

日期:2019-04-02点击:321

eureka集群-整合config配置中心

加入依赖

<dependencies> <!-- 监控 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!-- 安全验证 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <!-- Netflix --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> </dependencies> 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:admin@192.168.1.109:8761/eureka/, http://admin:admin@192.168.1.109: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:admin@192.168.1.109:8761/eureka/, http://admin:admin@192.168.1.109:8762/eureka/

读取配置文件内容

 @RestController public class TestController { @Value("${apuserName}") private String apuserName; @GetMapping(value = "/hello") public String hello() { return apuserName; } } //需要JAVA Spring Cloud大型企业分布式微服务云构建的B2B2C电子商务平台源码 一零三八七七四六二六

java B2B2C 仿淘宝电子商城系统

原文链接:https://yq.aliyun.com/articles/696554
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章