我的问题很简单。给定以下 POM:
<build>
<plugins>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>3.0.0-release</version>
<configuration>
<log4jConfiguration>${basedir}/src/main/resources/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
<props>${basedir}/src/main/resources/datanucleus.properties</props>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>DataNucleus_Repos2</id>
<name>DataNucleus Repository</name>
<url>http://www.datanucleus.org/downloads/maven2</url>
</repository>
<repository> <!-- Required for transaction-api transitive dep -->
<id>Java_Net_LEGACY</id>
<name>Java.Net legacy</name>
<url>http://download.java.net/maven/1/</url>
<layout>legacy</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>DataNucleus_2</id>
<url>http://www.datanucleus.org/downloads/maven2/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<scope>runtime</scope>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
</dependency>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
</dependencies>
鉴于我在预期的位置有文件 log4j.properties 和 datanucleus.properties,当我运行时
mvn compile
我得到(取自 datanucleus.log 文件)
19:36:11,297(主)错误 [DataNucleus.Enhancer] - DataNucleus 增强器完成但出现错误。请查看增强器日志以获取完整详细信息。某些类可能已得到增强,但有些导致错误为 API“JDO”创建 MetaDataManager 时出错:org.datanucleus.exceptions.NucleusException:为 API“JDO”创建 MetaDataManager 时出错:在 org.datanucleus.NucleusContext.getMetaDataManager(NucleusContext.java :964) 在 org.datanucleus.enhancer.DataNucleusEnhancer.getMetaDataManager(DataNucleusEnhancer.java:261) 在 org.datanucleus.enhancer.DataNucleusEnhancer.getFileMetadataForInput(DataNucleusEnhancer.java:716) 在 org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer. java:590) 在 org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1390)
原因:sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang java.lang.reflect.InvocationTargetException .reflect.Constructor.newInstance(Unknown Source) at org.datanucleus.plugin.NonManagedPluginRegistry.createExecutableExtension(NonManagedPluginRegistry.java:681) at org.datanucleus.plugin.PluginManager.createExecutableExtension(PluginManager.java:314) at org.datanucleus.NucleusContext .getMetaDataManager(NucleusContext.java:958) ... 还有 4 个
引起:java.lang.NoSuchFieldError: supportORM at org.datanucleus.api.jdo.metadata.JDOMetaDataManager.(JDOMetaDataManager.java:142) ... 11 更多
我想启用日志记录以查看我的应用程序正在执行哪些查询。需要注意的是,当从 POM 中删除 log4j 依赖项时,增强效果很好。当然,日志文件不再更新,但类得到了增强。
任何与上述行为相关的想法将不胜感激。