Spring AOP异常:Error creating bean with name ‘org.springframework.aop.aspectj.

简介: Spring AOP异常:Error creating bean with name ‘org.springframework.aop.aspectj.
Jul 26, 2020 11:43:22 AM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@4ee285c6: startup date [Sun Jul 26 11:43:22 CST 2020]; root of context hierarchy
Jul 26, 2020 11:43:22 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [Beans.xml]
Jul 26, 2020 11:43:23 AM org.springframework.context.support.ClassPathXmlApplicationContext refresh
WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Cannot create inner bean '(inner bean)#4493d195' of type [org.springframework.aop.aspectj.AspectJMethodBeforeAdvice] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#4493d195': Cannot resolve reference to bean 'selectAll' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'selectAll': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.aop.aspectj.AspectJExpressionPointcut]: No default constructor found; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
Jerry ends here!

解决方案

右键单击项目,选择Configure build path->Add External Jars:


将这三个jar加到Build Path里:


错误消失:


aspectjrt.jar:The runtime needed to execute a program using AspectJ. 基于AspectJ库的应用运行时必须的运行库。


下载地址:https://mvnrepository.com/artifact/org.aspectj/aspectjrt/1.6.9


aspectjweaver.jar: The AspectJ weaver introduces advices to java classes,给Java类引入对advices的支持


下载地址:https://mvnrepository.com/artifact/org.aspectj/aspectjweaver


aopalliance.jar: The AOP Alliance aims to ensure interoperability between Java/J2EE AOP implementations to build a larger AOP community.


下载地址:https://sourceforge.net/projects/aopalliance/

相关文章
|
8天前
|
XML Java 数据格式
Spring5系列学习文章分享---第一篇(概述+特点+IOC原理+IOC并操作之bean的XML管理操作)
Spring5系列学习文章分享---第一篇(概述+特点+IOC原理+IOC并操作之bean的XML管理操作)
14 1
|
8天前
|
XML druid Java
Spring5系列学习文章分享---第二篇(IOC的bean管理factory+Bean作用域与生命周期+自动装配+基于注解管理+外部属性管理之druid)
Spring5系列学习文章分享---第二篇(IOC的bean管理factory+Bean作用域与生命周期+自动装配+基于注解管理+外部属性管理之druid)
12 0
|
4天前
|
设计模式 缓存 程序员
Spring6(三):面向切面AOP(1)
Spring6(三):面向切面AOP(1)
11 1
|
5天前
|
监控 Java 数据安全/隐私保护
Spring AOP实现原理及其在企业应用中的实际应用
Spring AOP实现原理及其在企业应用中的实际应用
|
1天前
|
Java 微服务 Spring
微服务04---服务远程调用,根据订单id查询订单功能,根据id查询订单的同时,把订单所属的用户信息一起返回,Spring提供了一个工具RestTemplate,Bean写在对象前面,以后可以在任何地
微服务04---服务远程调用,根据订单id查询订单功能,根据id查询订单的同时,把订单所属的用户信息一起返回,Spring提供了一个工具RestTemplate,Bean写在对象前面,以后可以在任何地
|
4天前
|
Java Spring
Spring AOP(面向切面编程)详解
Spring AOP(面向切面编程)详解
|
4天前
|
XML Java 数据格式
Spring6(三):面向切面AOP(3)
Spring6(三):面向切面AOP(3)
8 0
|
4天前
|
SQL 安全 Java
Spring6(三):面向切面AOP(2)
Spring6(三):面向切面AOP(2)
7 0
|
5天前
|
Java 测试技术 数据安全/隐私保护
Spring Boot中的AOP编程实践
Spring Boot中的AOP编程实践
|
5天前
|
监控 Java 数据安全/隐私保护
Spring AOP实现原理及其在企业应用中的实际应用
Spring AOP实现原理及其在企业应用中的实际应用