一、先升级spring boot 版本到2.1.3web
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.3.RELEASE</version> <relativePath/> </parent>
若是是从2.0.0如下的版本升级的,升级到2.1.3后请注意redis配置 spring.redis.jedis.*redis
# 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
二、继承 spring cloud 相关依赖spring
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.3.RELEASE</version> <relativePath/> </parent> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
三、若是接入注册中心,增长consul依赖app
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-consul-discovery</artifactId> </dependency>
在application.properties增长注册中心须要的相关配置:dom
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
四、若是接入监控系统,增长配置spring-boot
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> <version>1.0.6</version> </dependency> |
在application.properties增长注册中心须要的相关配置:code
# 监控须要 management.endpoints.web.exposure.include = * management.endpoint.shutdown.enabled = false management.endpoint.health.show-details = always #支持分位计算 management.metrics.distribution.percentiles-histogram.http.server.requests = true |