springcloud config

谢谢参考:Spring Cloud Config - 统一配置中心_端碗吹水的技术博客_51CTO博客_配置中心_springcloud配置中心原理

首先有服务注册中心。。。

  1. 先配置springcloud config server端

创建springcloud项目,这个项目很简单和eureka一样,只要有application.yml就可以

 加入maven配置

<dependency>

            <groupId>org.springframework.cloud</groupId>

            <artifactId>spring-cloud-config-server</artifactId>

        </dependency>

然后配置application.yml

cloud:

    config:

      server:

        git: 

          #  Git仓库地址

          uri: http://aabb.git.com/18516779956/springcloud-config-file.git

          search-paths: "/**"  # 指定搜索根路径下的所有目录,若有多个路径使用逗号隔开

          #  Git仓库用户名或邮箱

          username: 123456

          #  Git仓库密码

          password: 88888

启动类加上 @EnableConfigServer

2.创建git仓库,下面的outsideserevice是一个服务,一个服务建一个文件夹,方便管理更多的项目配置,application-dev.yml,一定按规则来 懂得。

  1. springcloud 项目调用config端

Maven配置:

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-config-client</artifactId>

</dependency>

  启动类不要加什么配置,前提是你是springcloud项目能启动

eureka:

  client:

    service-url:

      defaultZone: http://123456:8888/eureka/

      

spring: 

  cloud:

    config:

      discovery:

        enabled: true

        service-id: schedulerservice # 注册中心的服务名

      profile: uat  # 指定配置文件的环境

  application: 

    name: outsideservice

    

server:

  port: 18083

mybatis: 

  #config-location: "classpath:mybatis/mapper/**/*.xml"        # mybatis配置文件所在路径

  mapper-locations: "classpath:mybatis/mapper/**/*.xml"                     # mapper映射文件

  type-aliases-package: "com.jlife.management.entity.**/*"            # 别名类所在包

pagehelper:

    helperDialect: mysql

    reasonable: true

    supportMethodsArguments: true

    params: count=countSql

  

##111

management:

#  endpoints:

#    enabled: false

#    web:

#      exposure:

#        include: '*'

  endpoint:

    health:

      show-details: ALWAYS

scheduled:

  Task:

    MqTask: '0/30 * * * * ?'#30秒执行一次

就能启动啦,项目config下的 dev啊,uat啊,pro啊,统统可以删掉啦。

最后建议 留个dev开发配置,做本地调试用

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值