blob: 34a5ced5b31bc731bc2995c9a8e39412db5ba8bf [file] [log] [blame]
rootdb0b96f2025-04-20 06:46:16 +00001<project xmlns="http://maven.apache.org/POM/4.0.0"
2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
Raverf79fdb62025-06-03 06:02:49 +00006 <!-- 基本坐标 -->
7 <modelVersion>4.0.0</modelVersion>
8 <groupId>com.example</groupId>
9 <artifactId>simple-maven-project</artifactId>
10 <version>1.0-SNAPSHOT</version>
rootdb0b96f2025-04-20 06:46:16 +000011
Raverf79fdb62025-06-03 06:02:49 +000012 <!-- 指定 Java 版本 -->
13 <properties>
14 <!-- 使用 Java 9,以支持接口中的 private 方法 -->
15 <maven.compiler.source>9</maven.compiler.source>
16 <!-- 如果还没定义,请添加 QueryDSL 版本 -->
17 <querydsl.version>5.0.0</querydsl.version>
18 </properties>
rootdb0b96f2025-04-20 06:46:16 +000019
Raverf79fdb62025-06-03 06:02:49 +000020 <!-- 添加依赖 -->
21 <dependencies>
22 <!-- Apache Commons Lang3,用于 Pair 等工具类 -->
23 <dependency>
24 <groupId>org.apache.commons</groupId>
25 <artifactId>commons-lang3</artifactId>
26 <version>3.12.0</version>
27 </dependency>
28 <dependency>
29 <groupId>javax.persistence</groupId>
30 <artifactId>javax.persistence-api</artifactId>
31 <version>2.2</version>
32 </dependency>
33 <dependency>
34 <groupId>org.hibernate</groupId>
35 <artifactId>hibernate-core</artifactId>
36 <version>5.6.14.Final</version>
37 </dependency>
38 <dependency>
39 <groupId>com.mysql</groupId>
40 <artifactId>mysql-connector-j</artifactId>
41 <version>8.0.32</version>
42 </dependency>
43 <dependency>
44 <groupId>org.slf4j</groupId>
45 <artifactId>slf4j-api</artifactId>
46 <version>1.7.36</version>
47 </dependency>
48 <!-- QueryDSL -->
49 <dependency>
50 <groupId>com.querydsl</groupId>
51 <artifactId>querydsl-jpa</artifactId>
52 <version>${querydsl.version}</version>
53 </dependency>
54 <dependency>
55 <groupId>com.querydsl</groupId>
56 <artifactId>querydsl-apt</artifactId>
57 <version>${querydsl.version}</version>
58 <scope>provided</scope>
59 </dependency>
60 <dependency>
61 <groupId>javax.annotation</groupId>
62 <artifactId>javax.annotation-api</artifactId>
63 <version>1.3.2</version>
64 </dependency>
65 <!-- JUnit Jupiter API & Engine for writing and running tests -->
66 <dependency>
67 <groupId>org.junit.jupiter</groupId>
68 <artifactId>junit-jupiter</artifactId>
69 <version>5.9.1</version>
70 <scope>test</scope>
71 </dependency>
72 <!-- JUnit Jupiter Engine -->
73 <dependency>
74 <groupId>org.junit.jupiter</groupId>
75 <artifactId>junit-jupiter-engine</artifactId>
76 <version>5.9.1</version>
77 <scope>test</scope>
78 </dependency>
79 <!-- 添加 Querydsl 核心依赖 -->
80 <dependency>
81 <groupId>com.querydsl</groupId>
82 <artifactId>querydsl-core</artifactId>
83 <version>5.0.0</version>
84 </dependency>
85 <!-- 添加 Querydsl APT,仅在编译时使用 -->
86 <dependency>
87 <groupId>com.querydsl</groupId>
88 <artifactId>querydsl-apt</artifactId>
89 <version>5.0.0</version>
90 <scope>provided</scope>
91 </dependency>
rootcd436562025-05-08 14:09:19 +000092
Raverf79fdb62025-06-03 06:02:49 +000093 <dependency>
94 <groupId>org.springframework.boot</groupId>
95 <artifactId>spring-boot-starter-web</artifactId>
96 <version>2.5.6</version> <!-- 根据需要调整版本 -->
97 </dependency>
98 </dependencies>
99
100 <!-- 构建配置 -->
101 <build>
102 <plugins>
103 <!-- 编译插件,设定 Java 9 编译 -->
104 <plugin>
105 <groupId>org.apache.maven.plugins</groupId>
106 <artifactId>maven-compiler-plugin</artifactId>
107 <version>3.8.1</version>
108 <configuration>
109 <release>9</release>
110 <compilerArgs>
111 <arg>--add-modules</arg>
112 <arg>java.xml.ws.annotation</arg>
113 </compilerArgs>
114 <annotationProcessorPaths>
115 <path>
116 <groupId>com.querydsl</groupId>
117 <artifactId>querydsl-apt</artifactId>
118 <version>${querydsl.version}</version>
119 <classifier>jpa</classifier>
120 </path>
121 <path>
122 <groupId>com.querydsl</groupId>
123 <artifactId>querydsl-jpa</artifactId>
124 <version>${querydsl.version}</version>
125 </path>
126 <path>
127 <groupId>javax.annotation</groupId>
128 <artifactId>javax.annotation-api</artifactId>
129 <version>1.3.2</version>
130 </path>
131 <path>
132 <groupId>javax.persistence</groupId>
133 <artifactId>javax.persistence-api</artifactId>
134 <version>2.2</version>
135 </path>
136 </annotationProcessorPaths>
137 <generatedSourcesDirectory>${project.build.directory}/generated-sources/java</generatedSourcesDirectory>
138 </configuration>
139 </plugin>
140 <!-- 执行插件,方便 mvn exec:java 直接运行 -->
141 <plugin>
142 <groupId>org.codehaus.mojo</groupId>
143 <artifactId>exec-maven-plugin</artifactId>
144 <version>3.1.0</version>
145 <configuration>
146 <mainClass>api.ApiMain</mainClass>
147 </configuration>
148 </plugin>
149 <plugin>
150 <groupId>com.mysema.maven</groupId>
151 <artifactId>apt-maven-plugin</artifactId>
152 <version>1.1.3</version>
153 <executions>
154 <execution>
155 <goals>
156 <goal>process</goal>
157 </goals>
158 <configuration>
159 <outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory>
160 <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
161 </configuration>
162 </execution>
163 </executions>
164 </plugin>
165 <plugin>
166 <groupId>org.apache.maven.plugins</groupId>
167 <artifactId>maven-surefire-plugin</artifactId>
168 <version>2.22.2</version>
169 <configuration>
170 <includes>
171 <include>**/*Test.java</include>
172 </includes>
173 <!-- 确保 test 可以访问 main 的类 -->
174 <useSystemClassLoader>true</useSystemClassLoader>
175 <useManifestOnlyJar>false</useManifestOnlyJar>
176 </configuration>
177 </plugin>
178
179 <plugin>
180 <groupId>org.springframework.boot</groupId>
181 <artifactId>spring-boot-maven-plugin</artifactId>
182 <version>2.5.6</version>
183 </plugin>
184 <!-- Optional: 将生成目录加入编译生命周期 -->
185 <plugin>
186 <groupId>org.codehaus.mojo</groupId>
187 <artifactId>build-helper-maven-plugin</artifactId>
188 <version>3.2.0</version>
189 <executions>
190 <execution>
191 <id>add-source</id>
192 <phase>generate-sources</phase>
193 <goals>
194 <goal>add-source</goal>
195 </goals>
196 <configuration>
197 <sources>
198 <source>${project.build.directory}/generated-sources/java</source>
199 </sources>
200 </configuration>
201 </execution>
202 </executions>
203 </plugin>
204 <!-- 添加 APT 插件配置,生成 Q 类 -->
205 <plugin>
206 <groupId>com.mysema.maven</groupId>
207 <artifactId>apt-maven-plugin</artifactId>
208 <version>1.1.3</version>
209 <executions>
210 <execution>
211 <goals>
212 <goal>process</goal>
213 </goals>
214 <configuration>
215 <!-- 生成目录,可根据项目实际调整 -->
216 <outputDirectory>target/generated-sources/java</outputDirectory>
217 <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
218 </configuration>
219 </execution>
220 </executions>
221 </plugin>
222 </plugins>
223 </build>
rootdb0b96f2025-04-20 06:46:16 +0000224
rootcd436562025-05-08 14:09:19 +0000225</project>