gpt4 book ai didi

spring-boot - Spring Boot 2 + Java 9 + Querydsl

转载 作者:行者123 更新时间:2023-12-03 17:15:21 24 4
gpt4 key购买 nike

我已成功将我的应用程序(Spring Boot + Java + Maven)更新到 Spring Boot 2。现在我正在尝试更新到 Java 9。

根据 Nicolas Fränkel 的博客文章 (Migrating a Spring Boot application to Java 9 - Compatibility),我在不使用模块信息文件的情况下完成了更新到 Java 9。但是当我创建这样的文件时,apt-maven-plugin 会卡在创建 Q-types 上。

有没有人使用 Java 9 + Maven + Querydsl 成功完成?

我的 apt-maven-plugin 的 Maven 配置如下所示:

     <plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>

当我运行 mvn generate-sources 时,插件只打印一堆错误消息,不生成任何类并报告成功:
$ mvn generate-sources
...
[INFO] --- apt-maven-plugin:1.1.3:process (default) @ app ---
.../src/main/java/module-info.java:9: error: module not found: java.validation
requires java.validation;
^
.../src/main/java/module-info.java:13: error: module not found: hibernate.jpa
requires hibernate.jpa;
^
...
21 errors
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.484 s
[INFO] Finished at: 2018-04-01T13:11:25+02:00
[INFO] ------------------------------------------------------------------------

最佳答案

一起使用 QueryDSL + Mapstruct 和 Lombok:

<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/annotations</outputDirectory>
<processors>
<processor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</processor>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
<processor>org.mapstruct.ap.MappingProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
</plugin>

关于spring-boot - Spring Boot 2 + Java 9 + Querydsl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49597466/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com