初始提交:部署 Spring Boot 应用

This commit is contained in:
2025-09-26 00:29:15 +08:00
commit 6958c081d4
60 changed files with 3664 additions and 0 deletions

192
pom.xml Normal file
View File

@@ -0,0 +1,192 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.light</groupId>
<artifactId>light-delivery</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Light Delivery Backend</name>
<description>Backend for Light Delivery Mini Program</description>
<!-- 使用 Spring Boot 3.1.4 作为父项目,统一管理依赖版本 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<!-- 定义 Java 17 版本Spring Boot 3.x 要求 JDK 17 及以上 -->
<java.version>17</java.version>
<lombok.version>1.18.38</lombok.version>
<mysql.version>8.0.33</mysql.version>
<!-- Docker镜像相关属性 -->
<docker.image.prefix>light</docker.image.prefix>
<!-- Jib 插件版本 -->
<jib-maven-plugin.version>3.3.1</jib-maven-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- 导入 Spring Modulith BOM 以统一管理其依赖版本 -->
<!-- <dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-bom</artifactId>
<version>${spring-modulith.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency> -->
<!-- 如果需要指定其他第三方依赖版本,也可在此处添加 -->
</dependencies>
</dependencyManagement>
<dependencies>
<!-- ========== Spring Boot Starters (Web & Data) ========== -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId> <!-- Web starter 通常已包含,检查是否必要 -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <!-- 版本由父POM管理移除显式版本 -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.38</version>
</dependency>
<!-- JJWT (确保版本与 Spring Boot 3 和 Java 17 兼容) -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version> <!-- 使用较新的 API 版本 -->
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId> <!-- 或 jjwt-gson -->
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>
<!-- 添加 Tomcat embed core 以支持 HTTPS 重定向配置 -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</dependency>
<!-- ========== Database ========== -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<!-- ========== Development ========== -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!-- ========== Test Dependencies ========== -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<!-- 可选:添加 Maven Compiler Plugin 明确指定 Java 版本 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<!-- Use forked compilation to avoid annotation processor classloader issues -->
<fork>true</fork>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.38</version> <!-- 请确保此处版本与你项目中的Lombok依赖版本一致 -->
</path>
<!-- 如果你项目中有其他注解处理器,也需要在这里显式添加 -->
</annotationProcessorPaths>
</configuration>
</plugin>
<!-- Jib Docker Plugin -->
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>${jib-maven-plugin.version}</version>
<configuration>
<from>
<image>openjdk:17-jdk-slim</image>
</from>
<to>
<image>light-delivery</image>
<tags>
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
</to>
<container>
<ports>
<port>8080</port>
</ports>
<creationTime>USE_CURRENT_TIMESTAMP</creationTime>
</container>
</configuration>
</plugin>
</plugins>
</build>
</project>