datanucleus工具如何运行文件进行增强?
为了增强类并使普通 Java 类“持久化”,我使用了 DataNucleus 增强器。我遇到的问题是:没有文件可以运行 datanucleus 工具(错误日志如下所示),因此 datanucleus 没有增强类。 datanucleus如何运行文件进行增强?
Pom.xml
datanucleus 的依赖
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>4.0.5</version>
<!--<scope>compile</scope> -->
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>4.0.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>4.0.9</version>
<scope>runtime</scope>
</dependency>
Datanucleus 增强插件
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>5.2.1</version>
<configuration>
<api>JDO</api>
<persistenceUnitName>MyUnit_Example</persistenceUnitName> <!-- todo: change persistance name-->
<log4jConfiguration>${pom.basedir}/data/log4j.properties</log4jConfiguration>
<generateConstructor>true</generateConstructor>
<verbose>true</verbose>
<alwaysDetachable>true</alwaysDetachable>
<metadataIncludes>${pom.basedir}/dir_name_1/dir_name_2/model**/*.class</metadataIncludes>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
警告列表
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.mortbay.jetty:servlet-api:jar:2.5-6.0.0beta12 is missing, no dependency information available
[INFO]
[INFO] --- datanucleus-maven-plugin:5.2.1:enhance (default-cli) @ forsteinrichtung ---
[WARNING] No files to run DataNucleus tool 'org.datanucleus.enhancer.DataNucleusEnhancer'
For to enhance the classes and to make normal Java classes "persistable", I have used DataNucleus Enhancer. The issue I am having is: No files to run datanucleus tool (error log shown below) and because of that datanucleus is not enhancing the classes. How the datanucleus run the files for enhancement?
Pom.xml
Dependencies of datanucleus
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>4.0.5</version>
<!--<scope>compile</scope> -->
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>4.0.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>4.0.9</version>
<scope>runtime</scope>
</dependency>
Datanucleus Plugin for enhance
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>5.2.1</version>
<configuration>
<api>JDO</api>
<persistenceUnitName>MyUnit_Example</persistenceUnitName> <!-- todo: change persistance name-->
<log4jConfiguration>${pom.basedir}/data/log4j.properties</log4jConfiguration>
<generateConstructor>true</generateConstructor>
<verbose>true</verbose>
<alwaysDetachable>true</alwaysDetachable>
<metadataIncludes>${pom.basedir}/dir_name_1/dir_name_2/model**/*.class</metadataIncludes>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
Warning list
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.mortbay.jetty:servlet-api:jar:2.5-6.0.0beta12 is missing, no dependency information available
[INFO]
[INFO] --- datanucleus-maven-plugin:5.2.1:enhance (default-cli) @ forsteinrichtung ---
[WARNING] No files to run DataNucleus tool 'org.datanucleus.enhancer.DataNucleusEnhancer'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的增强课程设置,希望能帮助您找到解决方案。您需要添加 persistence.xml,更新 Datanucleus 依赖项工件版本,并为 datanuclues 添加 javax.jdo 依赖项,该依赖项为 java 模型抽象提供了接口以实现持久性。
pom.xml
Datanucleus 的依赖性
用于增强的 Datanucleus 插件
persistence.xml
persistence.xml
的位置是“resources > META-INF > ”。持久性.xml”。如果persistence.xml
不存在,则需要创建新的persistence.xml
。My setup for enhance the classes, I hope it could help you to find a solution. You need to add a persistence.xml, update the Datanucleus dependency artifact versions and add a dependency of javax.jdo for datanuclues which provides an interface to java model abstraction for persistence.
pom.xml
Depandancy for Datanucleus
Datanucleus Plugin for enhance
persistence.xml
The location for
persistence.xml
is "resources > META-INF > persistence.xml". Ifpersistence.xml
does not exist then one need to create newpersistence.xml
.