今天学习spring的AOP注解式开发,出现了Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderService' defined in file
排除异常
-
检查spring配置文件路径是否错误
-
检查各类注解是否添加
@Component
@Controller
@Service
@Repository
-
检查maven依赖是否冲突
-
检查AOP注解是否错误
前三项检查均无错误
第四项发现错误:后置通知注解没有添加切点表达式,导致指向该通知时找不到目标对象,所以提示 'orderService' 无法找到
修改之后可以正常运行
编写代码时要细心啊