当前位置: 代码迷 >> J2EE >> ->Spring 中使用Before advice报了一堆错<该如何解决
  详细解决方案

->Spring 中使用Before advice报了一堆错<该如何解决

热度:201   发布时间:2016-04-22 02:41:41.0
---------------->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的类是什么。
  相关解决方案