错误 @annotation 切入点表达式仅在 Java 5 合规级别或更高级别受支持
Error the @annotation pointcut expression is only supported at Java 5 compliance level or above
我遇到了 Error when using AspectJ AOP with Java 7
中描述的相同问题
但提供的解决方案无济于事。
- 我已经将 spring-aspectjweaver 和 aspectjrt 升级到 1.7.2
- 将 org.springframework.aspects 的版本增加到 3.2.1
- Java 7
- Tomact 6
我正在使用 build.gradle 加载它。
添加的依赖项:
compile(group: 'org.aspectj', name: 'aspectjrt', version: '1.7.2')
compile(group: 'org.aspectj', name: 'aspectjweaver', version: '1.7.2')
compile(group: 'org.springframework', name: 'spring-aspects', version: '3.2.1.RELEASE')
compile(group: 'org.springframework', name: 'spring-aop', version: '3.2.1.RELEASE')
compile(group: 'org.springframework', name: 'spring-context', version: '3.2.1.RELEASE')
compile(group: 'org.springframework', name: 'spring-beans', version: '3.2.1.RELEASE')
compile(group: 'org.springframework', name: 'spring-core', version: '3.2.1.RELEASE')
compile(group: 'org.springframework', name: 'spring-expression', version: '3.2.1.RELEASE')
错误堆栈跟踪
org.springframework.beans.factory.BeanCreationException: **Error creating bean with name 'transfersComponent' defined in URL [jar:file:/C:/.some path to jar ./com/barclays/internet/aggregate/component/TransfersComponent.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean** 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.googlecode.ehcache.annotations.config.internalEhCacheCachingAdvisor': Cannot resolve reference to bean 'com.googlecode.ehcache.annotations.impl.CacheStaticMethodMatcherPointcut#0' while setting bean property 'pointcut'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.googlecode.ehcache.annotations.impl.CacheStaticMethodMatcherPointcut#0': Cannot resolve reference to bean 'com.googlecode.ehcache.annotations.impl.CacheAttributeSourceImpl#0' while setting bean property 'cacheAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.googlecode.ehcache.annotations.impl.CacheAttributeSourceImpl#0': Cannot resolve reference to bean 'ehCacheManager' while setting bean property 'cacheManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ehCacheManager' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error the @annotation pointcut expression is only supported at Java 5 compliance level or above
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:452)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1429)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:631)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:568)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:295)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1487)
at javax.management.remote.rmi.RMIConnectionImpl.access0(RMIConnectionImpl.java:97)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1328)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1420)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:848)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
at sun.rmi.transport.Transport.run(Transport.java:202)
at sun.rmi.transport.Transport.run(Transport.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:198)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:567)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.access0(TCPTransport.java:619)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:684)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:681)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:681)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Jul 16, 2015 9:50:43 AM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
如果是Eclipse,打开项目属性>Java编译器。将编译器合规级别设置为 1.7。
对于其他 IDE,只是 google 如何更改编译器合规性级别。
问题解决了,实际上我运行的项目由3个模块组成。在两个模块中,我将 jar 版本升级到 1.7.2,因为只有这两个模块在使用它。
但第三个模块也有依赖项,它正在下载旧版本的 spring-aspectweaver 1.5.3,甚至在对其他两个模块进行更改后,他们仍在从模块 1 的依赖项中选择旧的 jar .
从模块中删除旧的 jar 依赖项并硬删除旧的 jar 有帮助。
我曾经遇到过类似的问题,我在部署到 glassfish 服务器时收到了这条消息:
错误 @within 切入点表达式仅在 Java 5 合规级别或更高级别受支持。
原来是因为我的一个依赖项已经过时了。检查您怀疑的依赖版本。如果您有较早的工作版本并仅检查附加依赖项,则更容易发现。
我遇到了类似的问题。
以下 link 有帮助:
https://coderwall.com/p/8tbjdg/aspectj-complaining-about-java-5-compliance-level
我必须更新 aspectj 版本并且它有效。
我遇到了 Error when using AspectJ AOP with Java 7
中描述的相同问题但提供的解决方案无济于事。
- 我已经将 spring-aspectjweaver 和 aspectjrt 升级到 1.7.2
- 将 org.springframework.aspects 的版本增加到 3.2.1
- Java 7
- Tomact 6
我正在使用 build.gradle 加载它。
添加的依赖项:
compile(group: 'org.aspectj', name: 'aspectjrt', version: '1.7.2')
compile(group: 'org.aspectj', name: 'aspectjweaver', version: '1.7.2')
compile(group: 'org.springframework', name: 'spring-aspects', version: '3.2.1.RELEASE')
compile(group: 'org.springframework', name: 'spring-aop', version: '3.2.1.RELEASE')
compile(group: 'org.springframework', name: 'spring-context', version: '3.2.1.RELEASE')
compile(group: 'org.springframework', name: 'spring-beans', version: '3.2.1.RELEASE')
compile(group: 'org.springframework', name: 'spring-core', version: '3.2.1.RELEASE')
compile(group: 'org.springframework', name: 'spring-expression', version: '3.2.1.RELEASE')
错误堆栈跟踪
org.springframework.beans.factory.BeanCreationException: **Error creating bean with name 'transfersComponent' defined in URL [jar:file:/C:/.some path to jar ./com/barclays/internet/aggregate/component/TransfersComponent.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean** 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.googlecode.ehcache.annotations.config.internalEhCacheCachingAdvisor': Cannot resolve reference to bean 'com.googlecode.ehcache.annotations.impl.CacheStaticMethodMatcherPointcut#0' while setting bean property 'pointcut'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.googlecode.ehcache.annotations.impl.CacheStaticMethodMatcherPointcut#0': Cannot resolve reference to bean 'com.googlecode.ehcache.annotations.impl.CacheAttributeSourceImpl#0' while setting bean property 'cacheAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.googlecode.ehcache.annotations.impl.CacheAttributeSourceImpl#0': Cannot resolve reference to bean 'ehCacheManager' while setting bean property 'cacheManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ehCacheManager' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error the @annotation pointcut expression is only supported at Java 5 compliance level or above
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:452)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1429)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:631)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:568)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:295)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1487)
at javax.management.remote.rmi.RMIConnectionImpl.access0(RMIConnectionImpl.java:97)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1328)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1420)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:848)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
at sun.rmi.transport.Transport.run(Transport.java:202)
at sun.rmi.transport.Transport.run(Transport.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:198)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:567)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.access0(TCPTransport.java:619)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:684)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:681)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:681)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Jul 16, 2015 9:50:43 AM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
如果是Eclipse,打开项目属性>Java编译器。将编译器合规级别设置为 1.7。 对于其他 IDE,只是 google 如何更改编译器合规性级别。
问题解决了,实际上我运行的项目由3个模块组成。在两个模块中,我将 jar 版本升级到 1.7.2,因为只有这两个模块在使用它。
但第三个模块也有依赖项,它正在下载旧版本的 spring-aspectweaver 1.5.3,甚至在对其他两个模块进行更改后,他们仍在从模块 1 的依赖项中选择旧的 jar .
从模块中删除旧的 jar 依赖项并硬删除旧的 jar 有帮助。
我曾经遇到过类似的问题,我在部署到 glassfish 服务器时收到了这条消息:
错误 @within 切入点表达式仅在 Java 5 合规级别或更高级别受支持。
原来是因为我的一个依赖项已经过时了。检查您怀疑的依赖版本。如果您有较早的工作版本并仅检查附加依赖项,则更容易发现。
我遇到了类似的问题。 以下 link 有帮助:
https://coderwall.com/p/8tbjdg/aspectj-complaining-about-java-5-compliance-level
我必须更新 aspectj 版本并且它有效。