亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

spring aop 配置問題

配置了aop就一直報錯 大神求助

警告: Exception encountered during context initialization - cancelling refresh attempt

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aspectAspect' defined in URL [file:/E:/IdeaProjects/SpringBasic/out/production/SpringBasic/spring-aop-schema-advice.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Cannot create inner bean '(inner bean)#21901ca8' 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)#21901ca8': Cannot resolve reference to bean 'pointcut' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pointcut': Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException


Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Cannot create inner bean '(inner bean)#21901ca8' 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)#21901ca8': Cannot resolve reference to bean 'pointcut' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pointcut': Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#21901ca8': Cannot resolve reference to bean 'pointcut' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pointcut': Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pointcut': Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException

Caused by: java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException


正在回答

8 回答

<!--添加aspectjweaver包 -->
?? ??? ?<dependency>
?? ??? ??? ?<groupId>org.aspectj</groupId>
?? ??? ??? ?<artifactId>aspectjweaver</artifactId>
?? ??? ??? ?<version>1.8.5</version>
?? ??? ?</dependency>

1 回復 有任何疑惑可以回復我~

maven添加依賴

<dependency>

<groupId>org.aspectj</groupId>

<artifactId>aspectjrt</artifactId>

<version>1.6.12</version>

</dependency>

<dependency>

<groupId>org.aspectj</groupId>

<artifactId>aspectjweaver</artifactId>

<version>1.6.12</version>

</dependency>

<dependency>

<groupId>cglib</groupId>

<artifactId>cglib</artifactId>

<version>2.2</version>

</dependency>


1 回復 有任何疑惑可以回復我~
#1

Elske63

感謝!
2019-11-03 回復 有任何疑惑可以回復我~

缺少aspectjweaver-1.8.10.jar,這個包

1 回復 有任何疑惑可以回復我~

這個問題怎么解決誰知道?。??


0 回復 有任何疑惑可以回復我~

看最后一句 ?缺少包aspectjweaver

2 回復 有任何疑惑可以回復我~

應該切入點的expression切入點表達式寫的不錯execution(*?com.peak.aop.schema.advice.biz.*.*(..)),表示執行biz包中的任意類中的任意方法,均可執行切面程序。

0 回復 有任何疑惑可以回復我~

配置文件

<beans?xmlns="http://www.springframework.org/schema/beans"
???????????????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
???????????????xmlns:aop="http://www.springframework.org/schema/aop"
???????????????xsi:schemaLocation="http://www.springframework.org/schema/beans?http://www.springframework.org/schema/beans/spring-beans.xsd
????????http://www.springframework.org/schema/aop?http://www.springframework.org/schema/aop/spring-aop.xsd">

<bean?id="aspectAspect"?class="com.peak.aop.schema.advice.Aspect"></bean>
<bean?id="aspectBiz"?class="com.peak.aop.schema.advice.biz.AspectBiz"></bean>

<aop:config>
???????<aop:pointcut?id="pointcut"?expression="execution(*?com.peak.aop.schema.advice.biz.*(..))"/>
???????<aop:aspect?id="aspectAOP"?ref="aspectAspect">
??????????????<aop:before?method="work"?pointcut-ref="pointcut"/>
???????</aop:aspect>
</aop:config>
</beans>


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Spring入門篇
  • 參與學習       268802    人
  • 解答問題       1026    個

為您帶來IOC和AOP的基本概念及用法,為后續高級課程學習打下基礎

進入課程

spring aop 配置問題

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號