读书人

-gt;Spring 中使用Before advice报了一堆

发布时间: 2013-09-11 17:27:29 作者: rapoo

---------------->Spring 中使用Before advice报了一堆错<-----------

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.config.internalAutoProxyCreator':

Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class

[org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator]: Constructor threw exception; nested exception is

java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor


就是这样写的:

Java code
package org.spring.test;import org.aspectj.lang.annotation.*;import org.springframework.stereotype.Component;@Aspect@Componentpublic class Log {        @Before("execution(public void org.spring.test.UserDAOImpl.save(org.spring.test.User))")    public void myLog() {        System.out.println("You can do sth before this!!!");    }}


[解决办法]
spring的aop是符合aop规范的,需要应用aopalliance.jar这个包,你可能没有这个包
[解决办法]
请根据错误信息查错:
java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
[解决办法]
你注入的userDAO,不是org.spring.test.UserDAOImpl类,看看你的spring配置文件userDAO的类是什么。

读书人网 >J2EE开发

热点推荐