root | db0b96f | 2025-04-20 06:46:16 +0000 | [diff] [blame] | 1 | <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 | |
| 6 | <!-- 基本坐标 --> |
| 7 | <modelVersion>4.0.0</modelVersion> |
| 8 | <groupId>com.example</groupId> |
| 9 | <artifactId>simple-maven-project</artifactId> |
| 10 | <version>1.0-SNAPSHOT</version> |
| 11 | |
| 12 | <!-- 指定 Java 版本 --> |
| 13 | <properties> |
root | cd43656 | 2025-05-08 14:09:19 +0000 | [diff] [blame] | 14 | <!-- 使用 Java 9,以支持接口中的 private 方法 --> |
| 15 | <maven.compiler.source>9</maven.compiler.source> |
root | ff0769a | 2025-05-18 17:24:41 +0000 | [diff] [blame] | 16 | <!-- 如果还没定义,请添加 QueryDSL 版本 --> |
| 17 | <querydsl.version>5.0.0</querydsl.version> |
root | db0b96f | 2025-04-20 06:46:16 +0000 | [diff] [blame] | 18 | </properties> |
| 19 | |
root | cd43656 | 2025-05-08 14:09:19 +0000 | [diff] [blame] | 20 | <!-- 添加依赖 --> |
| 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> |
root | 927f153 | 2025-05-09 05:33:32 +0000 | [diff] [blame] | 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> |
root | ff0769a | 2025-05-18 17:24:41 +0000 | [diff] [blame] | 39 | <groupId>com.mysql</groupId> |
| 40 | <artifactId>mysql-connector-j</artifactId> |
root | 927f153 | 2025-05-09 05:33:32 +0000 | [diff] [blame] | 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 | <dependency> |
| 49 | <groupId>org.slf4j</groupId> |
| 50 | <artifactId>slf4j-simple</artifactId> |
| 51 | <version>1.7.36</version> |
| 52 | </dependency> |
root | 0d8b11f | 2025-05-15 14:10:43 +0000 | [diff] [blame] | 53 | <!-- QueryDSL --> |
| 54 | <dependency> |
| 55 | <groupId>com.querydsl</groupId> |
| 56 | <artifactId>querydsl-jpa</artifactId> |
root | ff0769a | 2025-05-18 17:24:41 +0000 | [diff] [blame] | 57 | <version>${querydsl.version}</version> |
root | 0d8b11f | 2025-05-15 14:10:43 +0000 | [diff] [blame] | 58 | </dependency> |
| 59 | <dependency> |
| 60 | <groupId>com.querydsl</groupId> |
| 61 | <artifactId>querydsl-apt</artifactId> |
root | ff0769a | 2025-05-18 17:24:41 +0000 | [diff] [blame] | 62 | <version>${querydsl.version}</version> |
root | 0d8b11f | 2025-05-15 14:10:43 +0000 | [diff] [blame] | 63 | <scope>provided</scope> |
| 64 | </dependency> |
| 65 | <dependency> |
| 66 | <groupId>javax.annotation</groupId> |
| 67 | <artifactId>javax.annotation-api</artifactId> |
| 68 | <version>1.3.2</version> |
| 69 | </dependency> |
root | ff0769a | 2025-05-18 17:24:41 +0000 | [diff] [blame] | 70 | <!-- JUnit Jupiter API & Engine for writing and running tests --> |
| 71 | <dependency> |
| 72 | <groupId>org.junit.jupiter</groupId> |
| 73 | <artifactId>junit-jupiter</artifactId> |
| 74 | <version>5.9.1</version> |
| 75 | <scope>test</scope> |
| 76 | </dependency> |
| 77 | <!-- JUnit Jupiter Engine --> |
| 78 | <dependency> |
| 79 | <groupId>org.junit.jupiter</groupId> |
| 80 | <artifactId>junit-jupiter-engine</artifactId> |
| 81 | <version>5.9.1</version> |
| 82 | <scope>test</scope> |
| 83 | </dependency> |
| 84 | <!-- 添加 Querydsl 核心依赖 --> |
| 85 | <dependency> |
| 86 | <groupId>com.querydsl</groupId> |
| 87 | <artifactId>querydsl-core</artifactId> |
| 88 | <version>5.0.0</version> |
| 89 | </dependency> |
| 90 | <!-- 添加 Querydsl APT,仅在编译时使用 --> |
| 91 | <dependency> |
| 92 | <groupId>com.querydsl</groupId> |
| 93 | <artifactId>querydsl-apt</artifactId> |
| 94 | <version>5.0.0</version> |
| 95 | <scope>provided</scope> |
| 96 | </dependency> |
root | cd43656 | 2025-05-08 14:09:19 +0000 | [diff] [blame] | 97 | </dependencies> |
| 98 | |
| 99 | <!-- 构建配置 --> |
root | db0b96f | 2025-04-20 06:46:16 +0000 | [diff] [blame] | 100 | <build> |
| 101 | <plugins> |
root | cd43656 | 2025-05-08 14:09:19 +0000 | [diff] [blame] | 102 | <!-- 编译插件,设定 Java 9 编译 --> |
| 103 | <plugin> |
| 104 | <groupId>org.apache.maven.plugins</groupId> |
| 105 | <artifactId>maven-compiler-plugin</artifactId> |
| 106 | <version>3.8.1</version> |
| 107 | <configuration> |
| 108 | <release>9</release> |
root | 0d8b11f | 2025-05-15 14:10:43 +0000 | [diff] [blame] | 109 | <compilerArgs> |
| 110 | <arg>--add-modules</arg> |
| 111 | <arg>java.xml.ws.annotation</arg> |
| 112 | </compilerArgs> |
| 113 | <annotationProcessorPaths> |
| 114 | <path> |
| 115 | <groupId>com.querydsl</groupId> |
| 116 | <artifactId>querydsl-apt</artifactId> |
root | ff0769a | 2025-05-18 17:24:41 +0000 | [diff] [blame] | 117 | <version>${querydsl.version}</version> |
root | 0d8b11f | 2025-05-15 14:10:43 +0000 | [diff] [blame] | 118 | <classifier>jpa</classifier> |
| 119 | </path> |
| 120 | <path> |
| 121 | <groupId>com.querydsl</groupId> |
| 122 | <artifactId>querydsl-jpa</artifactId> |
root | ff0769a | 2025-05-18 17:24:41 +0000 | [diff] [blame] | 123 | <version>${querydsl.version}</version> |
root | 0d8b11f | 2025-05-15 14:10:43 +0000 | [diff] [blame] | 124 | </path> |
| 125 | <path> |
| 126 | <groupId>javax.annotation</groupId> |
| 127 | <artifactId>javax.annotation-api</artifactId> |
| 128 | <version>1.3.2</version> |
| 129 | </path> |
root | ff0769a | 2025-05-18 17:24:41 +0000 | [diff] [blame] | 130 | <path> |
| 131 | <groupId>javax.persistence</groupId> |
| 132 | <artifactId>javax.persistence-api</artifactId> |
| 133 | <version>2.2</version> |
| 134 | </path> |
root | 0d8b11f | 2025-05-15 14:10:43 +0000 | [diff] [blame] | 135 | </annotationProcessorPaths> |
| 136 | <generatedSourcesDirectory>${project.build.directory}/generated-sources/java</generatedSourcesDirectory> |
root | cd43656 | 2025-05-08 14:09:19 +0000 | [diff] [blame] | 137 | </configuration> |
| 138 | </plugin> |
| 139 | <!-- 执行插件,方便 mvn exec:java 直接运行 --> |
root | db0b96f | 2025-04-20 06:46:16 +0000 | [diff] [blame] | 140 | <plugin> |
| 141 | <groupId>org.codehaus.mojo</groupId> |
| 142 | <artifactId>exec-maven-plugin</artifactId> |
| 143 | <version>3.1.0</version> |
| 144 | <configuration> |
| 145 | <mainClass>api.ApiMain</mainClass> |
| 146 | </configuration> |
| 147 | </plugin> |
root | 0d8b11f | 2025-05-15 14:10:43 +0000 | [diff] [blame] | 148 | <plugin> |
| 149 | <groupId>com.mysema.maven</groupId> |
| 150 | <artifactId>apt-maven-plugin</artifactId> |
| 151 | <version>1.1.3</version> |
| 152 | <executions> |
| 153 | <execution> |
| 154 | <goals> |
| 155 | <goal>process</goal> |
| 156 | </goals> |
| 157 | <configuration> |
| 158 | <outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory> |
| 159 | <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor> |
| 160 | </configuration> |
| 161 | </execution> |
| 162 | </executions> |
| 163 | </plugin> |
root | ff0769a | 2025-05-18 17:24:41 +0000 | [diff] [blame] | 164 | <plugin> |
| 165 | <groupId>org.apache.maven.plugins</groupId> |
| 166 | <artifactId>maven-surefire-plugin</artifactId> |
| 167 | <version>2.22.2</version> |
| 168 | <configuration> |
| 169 | <includes> |
| 170 | <include>**/*Test.java</include> |
| 171 | </includes> |
| 172 | <!-- 确保 test 可以访问 main 的类 --> |
| 173 | <useSystemClassLoader>true</useSystemClassLoader> |
| 174 | <useManifestOnlyJar>false</useManifestOnlyJar> |
| 175 | </configuration> |
| 176 | </plugin> |
| 177 | <plugin> |
| 178 | <groupId>org.apache.maven.plugins</groupId> |
| 179 | <artifactId>maven-surefire-plugin</artifactId> |
| 180 | <version>2.22.2</version> |
| 181 | <configuration> |
| 182 | <includes> |
| 183 | <include>**/*Test.java</include> |
| 184 | </includes> |
| 185 | </configuration> |
| 186 | </plugin> |
| 187 | <!-- Optional: 将生成目录加入编译生命周期 --> |
| 188 | <plugin> |
| 189 | <groupId>org.codehaus.mojo</groupId> |
| 190 | <artifactId>build-helper-maven-plugin</artifactId> |
| 191 | <version>3.2.0</version> |
| 192 | <executions> |
| 193 | <execution> |
| 194 | <id>add-source</id> |
| 195 | <phase>generate-sources</phase> |
| 196 | <goals><goal>add-source</goal></goals> |
| 197 | <configuration> |
| 198 | <sources> |
| 199 | <source>${project.build.directory}/generated-sources/java</source> |
| 200 | </sources> |
| 201 | </configuration> |
| 202 | </execution> |
| 203 | </executions> |
| 204 | </plugin> |
| 205 | <!-- 添加 APT 插件配置,生成 Q 类 --> |
| 206 | <plugin> |
| 207 | <groupId>com.mysema.maven</groupId> |
| 208 | <artifactId>apt-maven-plugin</artifactId> |
| 209 | <version>1.1.3</version> |
| 210 | <executions> |
| 211 | <execution> |
| 212 | <goals> |
| 213 | <goal>process</goal> |
| 214 | </goals> |
| 215 | <configuration> |
| 216 | <!-- 生成目录,可根据项目实际调整 --> |
| 217 | <outputDirectory>target/generated-sources/java</outputDirectory> |
| 218 | <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor> |
| 219 | </configuration> |
| 220 | </execution> |
| 221 | </executions> |
| 222 | </plugin> |
root | db0b96f | 2025-04-20 06:46:16 +0000 | [diff] [blame] | 223 | </plugins> |
| 224 | </build> |
| 225 | |
root | cd43656 | 2025-05-08 14:09:19 +0000 | [diff] [blame] | 226 | </project> |