编程语言
首页 > 编程语言> > java-使用带有datanucleus maven插件的单独模块中的JDO持久类

java-使用带有datanucleus maven插件的单独模块中的JDO持久类

作者:互联网

我有一个使用JDO可以持久保存到数据库的应用程序-我想使用第二个Java模块中的PersistenceCapable类.尽管应用程序会编译一个简单的测试,但会出现错误:

The class “com.hello.world.Foo” is not persistable This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.

好的,因此增强器插件未在第二个模块的类上运行.我不确定在构建过程中需要如何将增强器指向该模块.

>父项目
>第二个模块:com.hello.world.Foo

ParentProject pom.xml及其相关部分-问题是如何将增强器指向包含我的持久性类的第二个模块?

    <dependencies>


        <dependency>
            <groupId>Second Module</groupId>
            <artifactId>Second Module</artifactId>
            <version>1.0-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>javax.jdo</groupId>
            <artifactId>jdo-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-core</artifactId>
            <version>[3.2.0, 3.2.99)</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-api-jdo</artifactId>
            <version>[3.2.0, 3.2.99)</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-rdbms</artifactId>
            <version>[3.2.0, 3.2.99)</version>
            <scope>runtime</scope>
        </dependency>


    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.datanucleus</groupId>
                <artifactId>datanucleus-maven-plugin</artifactId>
                <version>3.3.0-release</version>
                <configuration>
                    <api>JDO</api>
                    <props>${basedir}/datanucleus.properties</props>
                    <log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
                    <verbose>true</verbose>
                </configuration>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

解决方法:

知道了-我不得不在问题中添加完全相同的pom.xml配置到第二个模块,并进行mvn安装,以在编译父模块之前增强这些类.同时从事Jetty和GAE.我错误地认为,父模块会增强模块依赖关系中包含的类.

感谢您的帮助DataNucleus!

标签:java,maven,datanucleus
来源: https://codeday.me/bug/20191009/1878952.html