1、先升级spring boot 版本到2.1.3

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>2.1.3.RELEASE</version>
</dependency>

如果是从2.0.0以下的版本升级的,升级到2.1.3后请注意redis配置 spring.redis.jedis.*

# redis配置
spring.redis.database = 15
spring.redis.host = 10.10.216.203
spring.redis.port = 6379
spring.redis.password = Redis@123
spring.redis.ssl = false
spring.redis.jedis.pool.max-active = 10
spring.redis.jedis.pool.max-idle = 10
spring.redis.jedis.pool.min-idle = 5

2、继承 spring cloud 相关依赖

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>2.1.3.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Greenwich.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

3、如果接入注册中心,增加consul依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>

在application.properties增加注册中心需要的相关配置:

spring.application.name = 自己项目的名称,在注册中心唯一
spring.cloud.consul.host = consul-client.okd.moon.test
spring.cloud.consul.port = 80
spring.cloud.consul.discovery.prefer-ip-address = true
spring.cloud.consul.discovery.instanceId = ${spring.application.name}-${random.value}
spring.cloud.consul.config.enabled = false
spring.cloud.consul.config.watch.wait-time = 20

4、如果接入监控系统,增加配置

在application.properties增加注册中心需要的相关配置:

07-24 00:03