13. 把eureka和deptprovider的配置设置到git
1.Git的文件
config-dept.yml
spring: profiles: active: dev --- server: port: 8001 #mybatis的配置 mybatis: type-aliases-package: com.wu.springcloud.pojo mapper-locations: classpath:mybatis/mapper/*.xml config-location: classpath:mybatis/mybatis-config.xml #spring的配置 spring: profiles: dev application: name: springcloud-config-dept #三个消费者名称一致是前提 datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: org.gjt.mm.mysql.Driver url: jdbc:mysql://localhost:3306/db01?useSSL=true&useUnicode=true&characterEncoding=utf-8 username: root password: root #注册eureka,服务注册到哪里 eureka: client: service-url: #集群发布 defaultZone: http://localhost:7001/eureka/,http://localhost:7002/eureka/,http://localhost:7003/eureka/ instance: instance-id: provider-dept-8001 #修改描述信息 info: app.name: xiaowu-springcloud company.name: yuzhibo.com --- server: port: 8001 #mybatis的配置 mybatis: type-aliases-package: com.wu.springcloud.pojo mapper-locations: classpath:mybatis/mapper/*.xml config-location: classpath:mybatis/mybatis-config.xml #spring的配置 spring: profiles: test application: name: springcloud-config-dept #三个消费者名称一致是前提 datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: org.gjt.mm.mysql.Driver url: jdbc:mysql://localhost:3306/db02?useSSL=true&useUnicode=true&characterEncoding=utf-8 username: root password: root #注册eureka,服务注册到哪里 eureka: client: service-url: #集群发布 defaultZone: http://localhost:7001/eureka/,http://localhost:7002/eureka/,http://localhost:7003/eureka/ instance: instance-id: provider-dept-8001 #修改描述信息 info: app.name: xiaowu-springcloud company.name: yuzhibo.com
config-eureka.yml
spring: profiles: active: dev --- server: port: 7001 #Spring的配置 spring: profiles: dev application: name: springcloud-config-eureka #eureka配置 eureka: instance: hostname: localhost client: register-with-eureka: false #表示是否注册自己 fetch-registry: false #表示自己是注册中心 service-url: #监控页面 defualtZone: http://localhost:7002/eureka/,http://localhost:7003/eureka/ #设置与其他两个eureka关联 如果是其他的电脑前面的localhost也要改变 --- server: port: 7001 #Spring的配置 spring: profiles: test application: name: springcloud-config-eureka #eureka配置 eureka: instance: hostname: localhost client: register-with-eureka: false #表示是否注册自己 fetch-registry: false #表示自己是注册中心 service-url: #监控页面 defualtZone: http://localhost:7002/eureka/,http://localhost:7003/eureka/ #设置与其他两个eureka关联 如果是其他的电脑前面的localhost也要改变
2.文件配置
加入pom依赖
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> <version>2.1.1.RELEASE</version> </dependency>
bootstarp.yml
spring: cloud: config: name: config-dept label: master profile: dev uri: http://localhost:3344
application.yml
spring:
application:
name: dept_8001
测试的效果