我正在使用Spring和AspectJ进行一些很好的编织,我在插入< context:load-time-weaver />之后遇到了这个问题.进入我的应用环境:
Caused by: java.lang.IllegalStateException: ClassLoader [sun.misc.Launcher$AppClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar
at org.springframework.context.weaving.DefaultContextLoadTimeWeaver.setBeanClassLoader(DefaultContextLoadTimeWeaver.java:83)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1419)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1391)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
... 21 common frames omitted
我是否需要自定义JVM才能运行AspectJ?我以前不记得必须这样做.
解决方法:
我找不到任何支持它的文档,但我很确定标准JVM不支持Spring的加载时编织方式. Spring’s guide to enabling LTW in different environments意味着“Generic Java applications” section就属于这种情况.