From d2b93b6ea410955101f36f266bb1cf0b0305ea6a Mon Sep 17 00:00:00 2001 From: chenyuan Date: Mon, 3 Aug 2026 11:00:22 +0800 Subject: [PATCH] chore: bootstrap Spring Boot application --- .gitignore | 4 + pom.xml | 107 ++++++++++++++++++ .../yau/digitalrmb/DigitalRmbApplication.java | 12 ++ src/main/resources/application-test.yml | 9 ++ src/main/resources/application.yml | 11 ++ .../resources/db/migration/V0__baseline.sql | 1 + .../digitalrmb/ApplicationContextTest.java | 22 ++++ 7 files changed, 166 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/com/yau/digitalrmb/DigitalRmbApplication.java create mode 100644 src/main/resources/application-test.yml create mode 100644 src/main/resources/application.yml create mode 100644 src/main/resources/db/migration/V0__baseline.sql create mode 100644 src/test/java/com/yau/digitalrmb/ApplicationContextTest.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b877dd3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +target/ +.idea/ +.env +*.log diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..2502b92 --- /dev/null +++ b/pom.xml @@ -0,0 +1,107 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 4.1.0 + + + + com.yau + digital-rmb-backend + 0.1.0-SNAPSHOT + digital-rmb-backend + 数字人民币教学仿真后端 + + + 17 + 3.5.17 + 3.0.3 + + + + + org.springframework.boot + spring-boot-starter-webmvc + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-oauth2-resource-server + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-flyway + + + org.flywaydb + flyway-mysql + + + com.baomidou + mybatis-plus-spring-boot4-starter + ${mybatis-plus.version} + + + com.mysql + mysql-connector-j + runtime + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc.version} + + + org.projectlombok + lombok + true + + + com.h2database + h2 + test + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + true + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/src/main/java/com/yau/digitalrmb/DigitalRmbApplication.java b/src/main/java/com/yau/digitalrmb/DigitalRmbApplication.java new file mode 100644 index 0000000..d9e24af --- /dev/null +++ b/src/main/java/com/yau/digitalrmb/DigitalRmbApplication.java @@ -0,0 +1,12 @@ +package com.yau.digitalrmb; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DigitalRmbApplication { + + public static void main(String[] args) { + SpringApplication.run(DigitalRmbApplication.class, args); + } +} diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml new file mode 100644 index 0000000..40dd36c --- /dev/null +++ b/src/main/resources/application-test.yml @@ -0,0 +1,9 @@ +spring: + datasource: + url: jdbc:h2:mem:digital_rmb;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=TRUE + username: sa + password: "" + driver-class-name: org.h2.Driver + flyway: + enabled: true + locations: classpath:db/migration diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..cdcf2c1 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,11 @@ +spring: + application: + name: digital-rmb-backend + datasource: + url: ${DIGITAL_RMB_DB_URL} + username: ${DIGITAL_RMB_DB_USERNAME} + password: ${DIGITAL_RMB_DB_PASSWORD} + driver-class-name: com.mysql.cj.jdbc.Driver + flyway: + enabled: true + locations: classpath:db/migration diff --git a/src/main/resources/db/migration/V0__baseline.sql b/src/main/resources/db/migration/V0__baseline.sql new file mode 100644 index 0000000..86431f0 --- /dev/null +++ b/src/main/resources/db/migration/V0__baseline.sql @@ -0,0 +1 @@ +-- baseline diff --git a/src/test/java/com/yau/digitalrmb/ApplicationContextTest.java b/src/test/java/com/yau/digitalrmb/ApplicationContextTest.java new file mode 100644 index 0000000..488d509 --- /dev/null +++ b/src/test/java/com/yau/digitalrmb/ApplicationContextTest.java @@ -0,0 +1,22 @@ +package com.yau.digitalrmb; + +import org.flywaydb.core.Flyway; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +import static org.assertj.core.api.Assertions.assertThat; + +@ActiveProfiles("test") +@SpringBootTest +class ApplicationContextTest { + + @Autowired + private Flyway flyway; + + @Test + void baselineMigrationIsApplied() { + assertThat(flyway.info().applied()).hasSize(1); + } +}