首页 > 其他 > 详细

微服务配置

时间:2019-12-25 21:03:48      阅读:90      评论:0      收藏:0      [点我收藏+]

bootstrap.yml文件如下:

spring:
  application:
    name: 微服务应用名
  cloud:
    config:
      label: ${config.label:dev}
      profile: ${config.profile:dev}
      discovery:
        enabled: true
        serviceId: config-server
eureka:
    instance:
      #Renew频率。默认是30秒,每30秒会向Eureka Server发起Renew操作。
      lease-renewal-interval-in-seconds: 30
      #服务失效时间。默认是90秒,Eureka Server在90秒内没有接收到来自Service Provider的Renew操作,就会把Service Provider剔除。
      lease-expiration-duration-in-seconds: 90
      prefer-ip-address: true
      instance-id: ${spring.cloud.client.ipAddress}:${server.port}
    client:
        serviceUrl:
            defaultZone: ${defaultZones:http://172.20.69.70:1111/eureka/,http://172.20.69.71:1111/eureka/}
        register-with-eureka: true

1、本地调式

将spring.cloud.config.discovery设置为false,然后将配置文件内容复制到application.yml中即可

2、打包部署环境

就是读取git上对应分支的配置,此时将spring.cloud.config.discovery设置为true

配置中心的配置文件application.yml如下

spring:
  application:
    name: config-server
#  profiles:
#    active: native
#  cloud:
#    config:
#      server:
#        native:
#          search-locations: ${config.url:E:/locationConfigCenter}
  cloud:
    config:
      discovery:
        enabled: true
      server:
        git:
          uri: ${config.url:http://git.timacloud.cn/TIMA-DMP/config-center.git}
          searchPaths: ${config.folder:dmp}
          username: ${config.username:jenkins.notify}
          password: ${config.password:J8GUrST5}
          force-pull: true
server:
  port: 2222
eureka:
  instance:
    #Renew频率。默认是30秒,每30秒会向Eureka Server发起Renew操作。
    lease-renewal-interval-in-seconds: 30
    #服务失效时间。默认是90秒,Eureka Server在90秒内没有接收到来自Service Provider的Renew操作,就会把Service Provider剔除。
    lease-expiration-duration-in-seconds: 90
    prefer-ip-address: true
    instance-id: ${spring.cloud.client.ipAddress}:${server.port}
  client:
      serviceUrl:
#          defaultZone: ${defaultZones:http://localhost:1111/eureka/}
          defaultZone: ${defaultZones:http://172.20.69.70:1111/eureka/,http://172.20.69.71:1111/eureka/}
      register-with-eureka: true

微服务配置

原文:https://www.cnblogs.com/gouhaiping/p/12098449.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!