未生成静态元模型类

Jac*_*liu 6 jhipster

我刚刚开始学习和使用 Jhipster。我有关于 JPA 静态元模型生成的问题。以下是我根据Jhipster网站所做的,但没有生成静态matemodel类(Class X_):

我创建了一个名为:SalesByDepartment 的实体。生成此实体后,我通过将 service 从 no 设置为 serviceImpl,并将 jpaMetamodelFiltering 设置为 true,从项目文件夹下的文件夹:.jhipster 更改了其 JOSN 文件。我的理解是,在对该实体的 JSON 文件进行此更改后,我需要重新运行实体子生成器来重新生成相同的实体以启用过滤功能。但是,我只能找到“SalesByDepartmentCriteria”和“SalesByDepartmentQueryService”。域包下没有类“SalesByDepartment_”。我还检查了 pom.xml,可以找到该插件:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <configuration>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.mapstruct</groupId>
                        <artifactId>mapstruct-processor</artifactId>
                        <version>${mapstruct.version}</version>
                    </path>
                    <!-- For JPA static metamodel generation -->
                    <path>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-jpamodelgen</artifactId>
                        <version>${hibernate.version}</version>
                    </path>

                </annotationProcessorPaths>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

我是否可以知道在域包下生成“SalesByDepartment_”是否还遗漏了其他内容?

感谢您的帮助。

顺便说一句,当我生成第一个项目时,它运行得很好。我采用了相同的方法,并在项目文件夹“com.xxx.domain”下自动创建了静态元模型类。在使用 Maven 构建过程后,我还可以在目标文件夹下找到它们。我猜想有什么问题,但仍然不知道为什么会这样。下面是我使用“jhipster”创建的两个项目的屏幕截图。A 是之前的项目,我可以生成静态元模型,但 B 不起作用: 在此处输入图像描述

小智 8

我也遇到了这个问题,我为自己找到的最好方法 - 将依赖项添加到 Maven 和注释处理器路径

    <dependencies>
         ...
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>${hibernate.version}</version>
        </dependency>
    </dependencies>
Run Code Online (Sandbox Code Playgroud)

注释处理器

 <build>
    <plugins>
        ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>11</source>
                <target>11</target>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-jpamodelgen</artifactId>
                        <version>${hibernate.version}</version>
                    </path>
                    ...
                </annotationProcessorPaths>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

希望它对某人有帮助)


Gaë*_*iou 5

JPA 静态元模型是由构建过程(maven 或 gradle)生成的,如JHipster 文档中所述,因此您只需构建应用程序,您将SalesByDepartment_.javatargetmaven 和buildgradle 下找到。