java - 通过 datanucleus maven 插件使用来自单独模块的 JDO 持久类

标签 java maven datanucleus

我有一个使用 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 install 来在编译父模块之前增强这些类。在 Jetty 和 GAE 上工作。我错误地认为父模块会增强模块依赖项中包含的类。

感谢您的帮助 DataNucleus!

关于java - 通过 datanucleus maven 插件使用来自单独模块的 JDO 持久类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19431412/

相关文章:

java - Hamcrest assertThat - 类型推断

java - 找不到符号,尽管它是在 java 中定义的

maven - 在一个阶段多次运行 exec-maven-plugin

java - Neodatis 对象 DB/DataNucleus - 如何定义索引?

java - 如何在 keystore 上为我的 key 对创建证书?

java - 目标运行时 WildFly 在 maven 测试后解包

java - 我在哪里放置 pom.xml 文件?

java - 在 JDO 查询中忽略大小写

java - 数据核、HBase、JDO : "A property named javax.jdo.PersistenceManagerFactoryClass must be specified"

java - 我的 Richfaces 4.0 项目无法与 ui 一起使用 :composition tag