Datanucleus Programmatic API Class Enhancement
2022-09-04 04:51:41
我正在使用Eclipse 3.7(OSGI),我可以手动增强(使用Datanucleus Eclipse插件和datanucleus-enhancer-2.1.0-release作为插件依赖项导入)
我现在尝试使用 API 类增强功能:http://www.datanucleus.org/products/accessplatform/jpa/enhancer.html#api
在类路径中使用 ASM 3.1 并编写以下代码:
DataNucleusEnhancer enhancer=new DataNucleusEnhancer("JDO","ASM");
enhancer.setVerbose(true);
enhancer.addClasses(...);
enhancer.enhance();
我得到:
You have selected to use ClassEnhancer "ASM" yet the JAR for that enhancer does not seem to be in the CLASSPATH!
org.datanucleus.enhancer.NucleusEnhanceException: You have selected to use ClassEnhancer "ASM" yet the JAR for that enhancer does not seem to be in the CLASSPATH!
at org.datanucleus.enhancer.DataNucleusEnhancer.init(DataNucleusEnhancer.java:224)
at org.datanucleus.enhancer.DataNucleusEnhancer.addClasses(DataNucleusEnhancer.java:406)
使用本教程中建议的代码:
JDOEnhancer enhancer = JDOHelper.getEnhancer();
enhancer.setVerbose(true);
enhancer.addClasses(...);
enhancer.enhance();
我得到:
javax.jdo.JDOFatalUserException: There are 0 services entries for the JDOEnhancer; there were no valid JDOEnhancer implementations found in the CLASSPATH. The file META-INF/services/javax.jdo.JDOEnhancer should name the implementation class.
有没有办法实现 API 类增强?