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

测试的效果

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值