hibernate 参数模型:将其与mapstruct和lombok一起使用会失败,但没有提示消息

r6vfmomb  于 2022-11-24  发布在  其他
关注(0)|答案(2)|浏览(188)

这里是我的相关pom.xml片段:

<properties>
    <java.version>11</java.version>
    <lombok.version>1.18.24</lombok.version>
    <org.mapstruct.version>1.5.2.Final</org.mapstruct.version>
    <hibernate-reactive.version>1.1.8.Final</hibernate-reactive.version>
    <hibernate-jpamodelgen.version>6.1.3.Final</hibernate-jpamodelgen.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.hibernate.reactive</groupId>
        <artifactId>hibernate-reactive-core</artifactId>
        <version>${hibernate-reactive.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.orm</groupId>
        <artifactId>hibernate-jpamodelgen</artifactId>
        <version>${hibernate-jpamodelgen.version}</version>
    </dependency>
    <dependency>
        <groupId>org.mapstruct</groupId>
        <artifactId>mapstruct</artifactId>
        <version>${org.mapstruct.version}</version>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>

如您所见,我使用的是lombok + mapstruct + japmodelgen
我的问题是,元模型没有生成,但我没有得到任何原因或消息。
我的实体类使用javax.persistence.* 注解进行了注解:

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "GITTBQDCF")
public class QdCF {
   //...
}

我还测试了maven-compiler-plugin的几种配置:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.10.1</version>
    <configuration>
        <release>${java.version}</release>
        <showWarnings>true</showWarnings>
        <verbose>true</verbose>
        <annotationProcessorPaths>
            <annotationProcessorPath>
                <groupId>org.hibernate.orm</groupId>
                <artifactId>hibernate-jpamodelgen</artifactId>
                <version>${hibernate-jpamodelgen.version}</version>
            </annotationProcessorPath>
            <annotationProcessorPath>
                <groupId>org.projectlombok</groupId>
                <version>${lombok.version}</version>
                <artifactId>lombok</artifactId>
            </annotationProcessorPath>
            <annotationProcessorPath>
                <groupId>org.projectlombok</groupId>
                <version>0.2.0</version>
                <artifactId>lombok-mapstruct-binding</artifactId>
            </annotationProcessorPath>
            <annotationProcessorPath>
                <groupId>org.mapstruct</groupId>
                <artifactId>mapstruct-processor</artifactId>
                <version>${org.mapstruct.version}</version>
            </annotationProcessorPath>
        </annotationProcessorPaths>
    </configuration>
</plugin>

但是,不会生成静态元模型类QdCF_

$ mvn compile
.....
.....
[WARNING] system modules path not set in conjunction with -source 11
[INFO] Hibernate JPA 2 Static-Metamodel Generator 6.1.3.Final
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  20.099 s
[INFO] Finished at: 2022-10-04T10:43:16+02:00
[INFO] ------------------------------------------------------------------------

我只能得到上面的消息:
[信息] Hibernate JPA 2静态元模型生成器6.1.3.最终版。
没别的了。我不知道我做错了什么...
有什么想法吗?
我是否可以启用某种额外的jpamodelgen日志记录?

uoifb46i

uoifb46i1#

Gradle也有同样的问题,并且存储库包含:Mapstruct + Lombok + Hibernate-jpamodelgen。稍后将尝试Delombok

> Task :compileJava
Note: Hibernate JPA 2 Static-Metamodel Generator 6.1.5.Final
BUILD SUCCESSFUL in 42s
1 actionable task: 1 executed

您是否尝试过在Maven中配置处理器订单?

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <compilerArguments>
            <processor>
                lombok.launch.AnnotationProcessorHider$AnnotationProcessor,org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
            </processor>
        </compilerArguments>
    </configuration>
</plugin>
gudnpqoy

gudnpqoy2#

"这对我有用"

<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>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>com.github.therapi</groupId>
                            <artifactId>therapi-runtime-javadoc-scribe</artifactId>
                            <version>0.15.0</version>
                        </path>
                        <annotationProcessorPath>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>1.18.24</version>
                        </annotationProcessorPath>
                    </annotationProcessorPaths>

                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>process</id>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <processors>
                                <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                            </processors>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-jpamodelgen</artifactId>
                        <version>5.4.3.Final</version>
                    </dependency>

                </dependencies>
            </plugin>
        </plugins>
    </build>

相关问题