加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何在Scala实体上运行Hibernate的JPAMetaModelEntityProcessor

发布时间:2020-12-16 19:24:21 所属栏目:安全 来源:网络整理
导读:我可以在我的pom.xml中运行基于 java的JPA-entites上运行Hibernate的jpamodelgen: dependency groupIdorg.hibernate/groupId artifactIdhibernate-jpamodelgen/artifactId version1.1.1.Final/version/dependency 但是,对于用Scala编写的实体来说,这当然是
我可以在我的pom.xml中运行基于 java的JPA-entites上运行Hibernate的jpamodelgen:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-jpamodelgen</artifactId>
    <version>1.1.1.Final</version>
</dependency>

但是,对于用Scala编写的实体来说,这当然是失败的.我试图使用maven-processor-plugin“手动”生成元模型,我的pom.xml看起来像这样:

<plugin>
    <groupId>org.bsc.maven</groupId>
    <artifactId>maven-processor-plugin</artifactId>
    <executions>
        <execution>
            <id>process</id>
            <goals>
                <goal>process</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
                <processors>
                    <!-- list of processors to use -->
                    <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                </processors>
                <!-- source output directory -->
                <outputDirectory>target/metamodel</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.3</version>
    <executions>
        <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>add-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>target/metamodel</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

但没有任何反应.

有人已经用Scala编写的JPA实体成功生成了JPA元模型吗?

谢谢.

解决方法

不要认为这是可能的,因为元模型生成器在javac中作为可插入注释处理器( http://jcp.org/en/jsr/detail?id=269)运行,即在Java源上运行.

但是,Javac不会理解你的scala源代码和scalac(据我所知)不支持并且不能支持JSR 269接口.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读