使用带有Datanucleus Maven插件的单独模块中的JDO Persistent类 [英] Using JDO Persistent classes from a separate module with datanucleus maven plugin

查看:109
本文介绍了使用带有Datanucleus Maven插件的单独模块中的JDO Persistent类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a working application that persists to a database using JDO - I want to use a PersistenceCapable class that's in a second java module. Although the app compiles a simple test gives the error:

类"com.hello.world.Foo"是不可持久的,这意味着它要么没有得到增强,要么文件的增强版本不在CLASSPATH中(或者被未增强的版本隐藏),或者找不到该类的元数据/注释.

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.

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

Ok, so the enhancer plugin is not running on the classes in the second module. I'm not sure what i need to do to point the enhancer at that module during the build.

  • ParentProject
  • 第二个模块:com.hello.world.Foo

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

ParentProject pom.xml with relevant parts - problem is how do i point the enhancer at the second module containing my persistent class?

    <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 install来使那些类增强编译父模块.同时从事Jetty和GAE.我错误地认为,父模块会增强模块依赖关系中包含的类.

got it - i had to add the exact same pom.xml config in the question to the second module and do a mvn install to get those classes enahnced before compiling the parent module. Working on both Jetty and GAE. I thought, wrongly, that the parent module would enhance classes included in the module dependencies.

感谢您对DataNucleus的帮助!

Thanks for your help DataNucleus!

这篇关于使用带有Datanucleus Maven插件的单独模块中的JDO Persistent类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆