在测试spring6aop实现开发的时候发现控制台报错如下信息:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userService’ defined in file [D:\JAVAWeb\TestJavaWeb\spring6\spring6-aop-realapp\target\classes\com\cxy\spring6\aop\app\UserService.class]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: com.cxy.spring6.aop.app [Xlint:invalidAbsoluteTypeName]
一开始一直以为是bean创建出错,然后检查了spring.xml文件的自动扫描类,发现也没有问题
上网找的时候,网上说是jar包版本不一致,修改后还是这个报错,后来看了网上很多教程,说是地址的问题,然后检查了类的地址,发现没有问题,然后就一直不知道错误的原因
最后,在Aspect类中抱着尝试的心态,吧execution表达式进行了修改
从这样:
@Pointcut("execution(* com.cxy.spring6.aop.app.add*(..))")
public void pointCutAdd(){}
修改为:
@Pointcut("execution(* com.cxy.spring6.aop..*(..))")
public void pointCutAdd(){}
我包的结构是:
我出错的原因在于,我在app包下直接写了方法,应该还有类来着,漏掉了