From ffc3b0c79252a8f17630bbaa0413f7e1b409e5e0 Mon Sep 17 00:00:00 2001 From: dingz Date: Fri, 27 Oct 2023 13:36:45 +0800 Subject: [PATCH] update compose --- compose-demo01.yml | 10 ++- pom.xml | 68 +++++++++++++++++++ .../demo/controller/UserController.java | 4 +- src/main/resources/application.yml | 4 +- 4 files changed, 79 insertions(+), 7 deletions(-) diff --git a/compose-demo01.yml b/compose-demo01.yml index 62452b3..5e93f3b 100644 --- a/compose-demo01.yml +++ b/compose-demo01.yml @@ -1,6 +1,5 @@ version: '3.9' name: demo01 -#Grafana官方提供模板地址:https://grafana.com/grafana/dashboards services: demo01: image: docker.io/library/demo01:1.0 @@ -12,8 +11,13 @@ services: - y9-share-net ports: - "7055:7055" - #volumes: - # - d:/docker-data/grafana:/var/lib/grafana + labels: + - "traefik.enable=true" + - "traefik.http.routers.demo01.entrypoints=web" + - "traefik.http.routers.demo01.rule=PathPrefix(`/demo01`)" + #- "traefik.http.services.demo01.loadbalancer.server.scheme=http" + #- "traefik.http.services.demo01.loadbalancer.server.port=7055" + #- "traefik.docker.network=y9-share-net" networks: y9-share-net: diff --git a/pom.xml b/pom.xml index bc30243..85361bd 100644 --- a/pom.xml +++ b/pom.xml @@ -104,4 +104,72 @@ + + + native + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + paketobuildpacks/builder-jammy-tiny + + gcr.io/paketo-buildpacks/graalvm + + gcr.io/paketo-buildpacks/java-native-image + + + true + 17.0.9 + --enable-preview + + + + + + process-aot + + process-aot + + + + + + org.graalvm.buildtools + native-maven-plugin + + + ${project.build.outputDirectory} + + true + + 22.3 + + + + add-reachability-metadata + + add-reachability-metadata + + + + + + + + + diff --git a/src/main/java/net/risesoft/demo/controller/UserController.java b/src/main/java/net/risesoft/demo/controller/UserController.java index cd138bb..49ba43e 100644 --- a/src/main/java/net/risesoft/demo/controller/UserController.java +++ b/src/main/java/net/risesoft/demo/controller/UserController.java @@ -10,7 +10,7 @@ import net.risesoft.demo.entity.User; import net.risesoft.demo.repository.UserRepository; @RestController -@RequestMapping("/api/users") +@RequestMapping public class UserController { private final UserRepository userRepository; @@ -20,7 +20,7 @@ public class UserController { this.userRepository = userRepository; } - @GetMapping + @GetMapping({"", "/", "/api/users"}) public List findAll(){ return userRepository.findAll(); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a63a03b..a50864a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -31,7 +31,7 @@ spring: name: demo01 cloud: consul: - host: localhost + host: host.docker.internal port: 8500 discovery: register-health-check: true @@ -44,7 +44,7 @@ spring: 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 + url: jdbc:mysql://host.docker.internal:3306/y9_public?serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&useCompression=true&useSSL=false&allowPublicKeyRetrieval=true username: root password: '12345678' hikari: