完整的报错:
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springConfig': warning no match for this type name: com.north.aop [Xlint:invalidAbsoluteTypeName]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springConfig': warning no match for this type name: com.north.aop [Xlint:invalidAbsoluteTypeName]
1、通知类有问题:
① 通知类 也要加上 @Component,还要加 @Aspect,因为 AOP 也归 Spring 管理,所以要加 @Aspect
② @Pointcut("") 这里面的路径错了。是目标类(切入类)的路径,即要被增强方法的路径,不是当前通知类的其它方法,这点要格外注意
2、目标类(切入类)有问题:
目标类(切入类)也要加上 @Component
3、Spring 配置有问题:
① @ComponentScan 扫描的是 指定包及其子包。这个路径写错了,就找不到 AOP 的路径