我有一个使用 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/