aspectjweaver.jar
运行后报了一大堆错误,挺吓人的,不要怕,这写错误可能是同一原因在不同地方重复出现;
错误太长,粘贴几段,分析一下
Exception encountered during context initialization - cancelling refresh attempt: org.Springframework.beans.factory.BeanCreationException: ERROR
creating bean with name 'loginLogDao' defined in file [D:\actionSpring\chapter\chapter1\target\classes\com\smart\dao\LoginLogDao.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0': cannot resolve reference to bean 'serviceMethod' while setting bean property 'pointcut'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'serviceMethod': failed to introspect bean class [org.springframework.aop.aspectj.AspectJExpressionPointcut] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
九月 19, 2018 11:43:19 上午 org.springframework.test.context.TestContextManager prepareTestinstance
严重:
Caught exception while allowing TestexecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@bc05a6] to prepare test instance [com.smart.service.UserServiceTest@729b1e]
java.lang.IllegalStateException: Failed to load APPlicationContext
Caused by: java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
Caused by: java.lang.ClassnotfoundException: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0':
Caused by: java.lang.ClassNotFoundException: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException
刚开始可能云里雾里的,从上到下,分析一下黑体部分,发现了关键问题:j
springframework.aop.aspectj.AspectJExpression Pointcut for lookup method metadata: could not find class that it depends on
Pointcut 使用时,寻找方法时找不到依赖的类
java.lang.IllegalStateException: Failed to load ApplicationContext
发现问题出在配置文件上,查一下applicationContect.xml且和aop:pointcut有关,发现:
<!-- 通过AOP配置提供事务增强,让service包下所有Bean的所有方法拥有事务 -->
<aop:config proxy-target-class="true">
<aop:pointcut id="serviceMethod"
expression=" execution(* com.smart.service..*(..))" />
<aop:advisor pointcut-ref="serviceMethod" advice-ref="txAdvice" />
</aop:config>
spring aop是用aspectj来实现的,是依赖关系!
AspectJ是动态代理的一种实现!而spring默认使用的就是AspectJ来实现的动态代理
使用时需要依赖于一些第三方库
java.lang.ClassNotFoundException: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException
找到缺少的类包weaver
下载aspectjweaver.jar ,网上很多资源,附一个下载链接:
导入该依赖包
有些人可能还缺少spring-aop.jar,这个一般使用IDE导入spring框架会有。
相关阅读
Spring contextConfigLocation默认加载文件的位置
在使用Spring框架的时候,如果我们使用的是XML文件配置Bean的方式的话,我们往往会在web.xml里面配置如下内容: <context-pa
@RequestMapping(value = "/produces", produces = "application/json"):表示将功能处理方法将生产json格式的数据,此时根据请求
servlet以及spring mvc实现bigpipe技术分享
使用Servlet分段输出构建BigPipe服务端BigPipe是一个重新设计的基础动态网页服务体系。大体思路是,分解网页成叫做Pagelets的小块,
Spring框架中@DateTimeFormat和@NumberFormat的用法
@DateTimeFormat是用来验证输入的日期格式;@NumberFormat是用来验证输入的数字格式。有时候,因为输入习惯或某些要求必须改变格式的
直接引用经典文章来源:https://blog.csdn.net/w05980598/article/details/79007194什么是微服务微服务的概念源于2014年3月Martin