diff --git a/pom.xml b/pom.xml index 0034e30..eaf642f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,23 +1,40 @@ - 4.0.0 org.springframework.boot spring-boot-starter-parent - 3.0.3 + 3.0.5 com.flagnote flagnote-service - 0.0.1-SNAPSHOT + 0.0.1 flagnote-service Demo project for Spring Boot 17 - 2022.0.1 + 17 + 17 + 17 + 2022.0.2 + flagnote + + org.springframework.cloud + spring-cloud-starter-zookeeper-discovery + + + org.springframework.cloud + spring-cloud-config-client + + + org.springframework.cloud + spring-cloud-starter-bootstrap + org.springframework.boot spring-boot-starter-actuator @@ -38,16 +55,10 @@ org.springframework.boot spring-boot-starter-aop - cn.hutool hutool-all - 5.8.10 + 5.8.18 org.projectlombok @@ -73,6 +84,27 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 17 + 17 + UTF-8 + true + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + org.springframework.boot spring-boot-maven-plugin @@ -85,6 +117,25 @@ + + + com.spotify + docker-maven-plugin + 1.2.2 + + http://rancher:42375 + + ${docker.image.prefix}/${project.artifactId}:${project.version} + src/main/docker + + + / + ${project.build.directory} + ${project.build.finalName}.jar + + + + diff --git a/src/main/docker/dockerfile b/src/main/docker/dockerfile new file mode 100644 index 0000000..312ed36 --- /dev/null +++ b/src/main/docker/dockerfile @@ -0,0 +1,8 @@ +FROM openjdk:17-slim +VOLUME /tmp +ADD flagnote-service-0.0.1.jar app.jar +RUN sh -c 'touch /app.jar' +RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone +RUN apt-get update && apt-get install -y curl +ENV JAVA_OPTS="" +ENTRYPOINT [ "sh", "-c", "exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ] \ No newline at end of file diff --git a/src/main/java/com/flagnote/note/NoteApplication.java b/src/main/java/com/flagnote/note/NoteApplication.java index ed095cf..099c747 100644 --- a/src/main/java/com/flagnote/note/NoteApplication.java +++ b/src/main/java/com/flagnote/note/NoteApplication.java @@ -3,10 +3,12 @@ package com.flagnote.note; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.web.bind.annotation.RestController; @SpringBootApplication @EnableAutoConfiguration +@EnableDiscoveryClient @RestController public class NoteApplication { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml deleted file mode 100644 index 51ac2fc..0000000 --- a/src/main/resources/application.yml +++ /dev/null @@ -1,50 +0,0 @@ -server: - address: 127.0.0.1 - port: 20000 - -spring: - application: - name: flagnote-service - profiles: - active: dev - codec: - max-in-memory-size: 10MB -# config: -# import: 'optional:configserver:http://localhost:9999' - data: - mongodb: - authentication-database: flagnote - database: flagnote - host: service.flagnote.com - port: 37017 - username: flagnote - password: flagnote1qazx - autoConnectRetry: true - socketKeepAlive: true - socketTimeout: 10000 - - - -management: -# server: -# address: 127.0.0.1 -# port: 29000 - endpoint: - shutdown: - enabled: true - health: - enabled: true - endpoints: - web: - base-path: /f2w8u47ie56edc93/actuator - exposure: - include: shutdown,health - -logging: - level: - org: - springframework: - data: - mongodb: - core: - MongoTemplate: DEBUG \ No newline at end of file diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..68cedb7 --- /dev/null +++ b/src/main/resources/bootstrap.yml @@ -0,0 +1,11 @@ +spring: + application: + name: flagnote-service + cloud: + config: + name: flagnote-service + profile: prd + uri: http://flagnote-config-01:8080/flagnote-config,http://flagnote-config-02:8080/flagnote-config + config: + import: optional:configserver:http://flagnote-config-01:8080/,optional:configserver:http://flagnote-config-02:8080/ +