一、先升級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 |