在Spring的配置文件里面配置AOP 例外通知时出现异常

b520xia 2013-03-11 04:43:44
Spring配置文件:
	<aop:config>
<aop:aspect id="sec" ref="provincesAop">
<aop:pointcut id="allAddMethod" expression="execution(* com.am8.mutual.action..*.*(..))"/>
<!-- 例外通知 -->
<aop:after-throwing method="throwingx" pointcut-ref="allAddMethod"/>
<!-- 前置通知 -->
<aop:before method="checkSecurity" pointcut-ref="allAddMethod" />
<!-- 后置通知 -->
<aop:after-returning method="after" pointcut-ref="allAddMethod"/>
</aop:aspect>
</aop:config>


java代码:
	 /**
* 例外通知
*/
private void throwingx(Exception execution){
System.out.println("*****************异常信息如下**************");
System.out.println(execution);
}


异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'provincesAction' defined in file [D:\apache-tomcat-6.0.33\webapps\am8\WEB-INF\classes\com\am8\mutual\resources\applicationContext-action.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': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut 

还有其它几个异常信息跟这个差不多
...全文
2842 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhaohaiwei1 2014-08-07
  • 打赏
  • 举报
回复
有没有加<dependency> <groupId> org.aspectj</groupId > <artifactId> aspectjweaver</artifactId > <version> 1.6.11</version > </dependency> 的依赖 新的aspectj中好像不包含 weaver包
tianma630 2013-03-11
  • 打赏
  • 举报
回复
吧整个配置文件贴出来
lvzg_005 2013-03-11
  • 打赏
  • 举报
回复
Constructor threw exception; nested exception is java.lang.IllegalArgumentException: 仔细查看切面类中方法上面的pointcut表达式是否书写正确
b520xia 2013-03-11
  • 打赏
  • 举报
回复
引用 7 楼 fangmingshijie 的回复:
你是不是开玩笑?你打印execution了
额 这个应该不关出这个异常的事儿吧 我就想看看
  • 打赏
  • 举报
回复
你是不是开玩笑?你打印execution了
b520xia 2013-03-11
  • 打赏
  • 举报
回复
引用 5 楼 fangmingshijie 的回复:
<aop:pointcut id="allAddMethod" expression="execution(* com.am8.mutual.action..*.*(..))"/> 这个应该配置在<aop:aspect>外部。
换在外部了 还是那些异常 刚才我没配置例外通知(throwingx)的时候 就没出任何异常 配了例外通知 就出了这些异常
  • 打赏
  • 举报
回复
<aop:pointcut id="allAddMethod" expression="execution(* com.am8.mutual.action..*.*(..))"/> 这个应该配置在<aop:aspect>外部。
b520xia 2013-03-11
  • 打赏
  • 举报
回复
引用 2 楼 flagiris 的回复:
applicationContext-action.xml里有名叫provincesAction的bean么?
哦 有看见了 是在我例外的一个 Spring 配置文件里面的
b520xia 2013-03-11
  • 打赏
  • 举报
回复
引用 2 楼 flagiris 的回复:
applicationContext-action.xml里有名叫provincesAction的bean么?
没有找到
菖蒲老先生 2013-03-11
  • 打赏
  • 举报
回复
applicationContext-action.xml里有名叫provincesAction的bean么?
b520xia 2013-03-11
  • 打赏
  • 举报
回复
顺便问下 例外通知是专门处理异常的吧??

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧