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

29
pom.xml
View File

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

View File

@ -29,12 +29,25 @@ server:
spring: spring:
application: application:
name: demo01 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: datasource:
driverClassName: com.mysql.cj.jdbc.Driver 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 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
username: root username: root
password: '12345678' password: '12345678'
hikari: hikari:
maximumPoolSize: 20 maximumPoolSize: 20
minimumIdle: 1 minimumIdle: 1
jpa: jpa: