Files
Bruno GaoandQwen-Coder 1849110f3f feat: implement batch 1 skeleton for Java service template
- Create parent POM with multi-module structure
- Set up four modules: tmpl-domain, tmpl-application, tmpl-infrastructure, tmpl-api
- Configure Spring Boot 3.4.1 with Java 21
- Add application configurations for dev/staging/prod
- Set up logging with structured JSON output
- Configure database with PostgreSQL and Flyway
- Add security configuration with minimal setup
- Include docker-compose for local development
- Add all necessary build and dependency management plugins

Co-authored-by: Qwen-Coder <[email protected]>
2026-02-12 12:51:20 +08:00

281 lines
12 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.1</version>
<relativePath/>
</parent>
<groupId>com.ljwx.tmpl</groupId>
<artifactId>java-service-template</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>java-service-template</name>
<description>Java 21 通用项目模板 - M2 实施基准</description>
<modules>
<module>tmpl-domain</module>
<module>tmpl-application</module>
<module>tmpl-infrastructure</module>
<module>tmpl-api</module>
</modules>
<properties>
<!-- ==================== 语言 ==================== -->
<java.version>21</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- ==================== 依赖版本 ==================== -->
<mapstruct.version>1.6.3</mapstruct.version>
<springdoc.version>2.8.3</springdoc.version>
<logstash-logback.version>8.0</logstash-logback.version>
<archunit.version>1.3.0</archunit.version>
<testcontainers.version>1.20.4</testcontainers.version>
<git-commit-id.version>9.0.1</git-commit-id.version>
<!-- ==================== 插件版本 ==================== -->
<spotless.version>2.43.0</spotless.version>
<google-java-format.version>1.24.0</google-java-format.version>
<spotbugs-maven.version>4.8.6.6</spotbugs-maven.version>
<owasp-dependency-check.version>11.1.1</owasp-dependency-check.version>
<jacoco.version>0.8.12</jacoco.version>
<!-- ==================== 门禁阈值与开关 ==================== -->
<jacoco.minimum.coverage>0.70</jacoco.minimum.coverage>
<!--
默认全跳过:保证批次1/本地快速验证不被覆盖率、漏洞库下载等阻断。
CI quality-gate 会显式 -Dxxx.skip=false 打开门禁。
-->
<jacoco.skip>true</jacoco.skip>
<spotbugs.skip>true</spotbugs.skip>
<dependency-check.skip>true</dependency-check.skip>
</properties>
<dependencyManagement>
<dependencies>
<!-- ===== 内部模块 ===== -->
<dependency>
<groupId>com.ljwx.tmpl</groupId>
<artifactId>tmpl-domain</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.ljwx.tmpl</groupId>
<artifactId>tmpl-application</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.ljwx.tmpl</groupId>
<artifactId>tmpl-infrastructure</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.ljwx.tmpl</groupId>
<artifactId>tmpl-api</artifactId>
<version>${project.version}</version>
</dependency>
<!-- ===== 第三方 ===== -->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>${springdoc.version}</version>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>${logstash-logback.version}</version>
</dependency>
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit5</artifactId>
<version>${archunit.version}</version>
</dependency>
<!-- Testcontainers BOM -->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>${testcontainers.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<!-- ===== 全局生效插件(显式声明,确保吃到 pluginManagement 配置) ===== -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- ===== Maven Compiler(MapStruct 处理器) ===== -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Amapstruct.defaultComponentModel=spring</arg>
</compilerArgs>
</configuration>
</plugin>
<!-- ===== Spotless 代码格式化 ===== -->
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless.version}</version>
<configuration>
<java>
<googleJavaFormat>
<version>${google-java-format.version}</version>
<style>AOSP</style>
</googleJavaFormat>
<removeUnusedImports/>
<importOrder>
<order>com.ljwx,com,org,javax,jakarta,java</order>
</importOrder>
</java>
</configuration>
</plugin>
<!-- ===== JaCoCo 覆盖率 ===== -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<configuration>
<skip>${jacoco.skip}</skip>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<phase>test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>check</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.minimum.coverage}</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<!-- ===== SpotBugs ===== -->
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven.version}</version>
<executions>
<execution>
<id>spotbugs-check</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>${spotbugs.skip}</skip>
<effort>Max</effort>
<threshold>Medium</threshold>
<failOnError>true</failOnError>
</configuration>
</plugin>
<!-- ===== OWASP Dependency Check ===== -->
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>${owasp-dependency-check.version}</version>
<executions>
<execution>
<id>dependency-check</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>${dependency-check.skip}</skip>
<failBuildOnCVSS>7</failBuildOnCVSS>
<suppressionFiles>
<!-- 多模块下使用根目录绝对引用,确保子模块能找到 -->
<suppressionFile>${maven.multiModuleProjectDirectory}/owasp-suppressions.xml</suppressionFile>
</suppressionFiles>
</configuration>
</plugin>
<!-- ===== git-commit-id ===== -->
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>${git-commit-id.version}</version>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>