add coonsul

This commit is contained in:
dingz 2023-10-24 19:42:29 +08:00
parent a23ac31046
commit 07c848a8f6
3 changed files with 45 additions and 8 deletions

View File

@ -47,8 +47,11 @@ services:
- "host.docker.internal:host-gateway"
networks:
- y9-share-net
volumes:
- d:/docker-data/consul:/bitnami/consul
environment:
- CONSUL_AGENT_MODE=server
- CONSUL_BOOTSTRAP_EXPECT=1
- CONSUL_ENABLE_UI=true
- CONSUL_HTTP_PORT_NUMBER=8500
ports:
- '8300:8300'
- '8301:8301'
@ -56,6 +59,8 @@ services:
- '8500:8500'
- '8600:8600'
- '8600:8600/udp'
volumes:
- d:/docker-data/consul:/bitnami/consul
networks:
y9-share-net:

29
pom.xml
View File

@ -16,7 +16,26 @@
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
<spring-cloud.version>2022.0.4</spring-cloud.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.ecwid.consul</groupId>
<artifactId>consul-api</artifactId>
<version>1.4.5</version>
</dependency>
<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>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -57,11 +76,11 @@
<scope>runtime</scope>
</dependency>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -29,6 +29,19 @@ server:
spring:
application:
name: demo01
cloud:
consul:
host: localhost
port: 8500
discovery:
register-health-check: true
healthCheckPath: ${server.servlet.context-path}/actuator/health
healthCheckInterval: 15s
metadata:
metrics: ${server.servlet.context-path}/actuator/prometheus
springboot: true
isv: risesoft
tags: test,y9
datasource:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/y9_public?serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&useCompression=true&useSSL=false&allowPublicKeyRetrieval=true