当前位置:编程学习 > JAVA >>

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

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 

还有其它几个异常信息跟这个差不多  --------------------编程问答-------------------- 顺便问下 例外通知是专门处理异常的吧?? --------------------编程问答-------------------- applicationContext-action.xml里有名叫provincesAction的bean么? --------------------编程问答--------------------
引用 2 楼 flagiris 的回复:
applicationContext-action.xml里有名叫provincesAction的bean么?

没有找到 --------------------编程问答--------------------
引用 2 楼 flagiris 的回复:
applicationContext-action.xml里有名叫provincesAction的bean么?

哦  有看见了 是在我例外的一个 Spring 配置文件里面的 --------------------编程问答--------------------  <aop:pointcut id="allAddMethod" expression="execution(* com.am8.mutual.action..*.*(..))"/>
这个应该配置在<aop:aspect>外部。 --------------------编程问答--------------------
引用 5 楼 fangmingshijie 的回复:
<aop:pointcut id="allAddMethod" expression="execution(* com.am8.mutual.action..*.*(..))"/>
这个应该配置在<aop:aspect>外部。

换在外部了 还是那些异常 刚才我没配置例外通知(throwingx)的时候 就没出任何异常 配了例外通知 就出了这些异常 --------------------编程问答-------------------- 你是不是开玩笑?你打印execution了 --------------------编程问答--------------------
引用 7 楼 fangmingshijie 的回复:
你是不是开玩笑?你打印execution了
额 这个应该不关出这个异常的事儿吧  我就想看看 --------------------编程问答-------------------- Constructor threw exception; nested exception is java.lang.IllegalArgumentException:
仔细查看切面类中方法上面的pointcut表达式是否书写正确 --------------------编程问答-------------------- 吧整个配置文件贴出来
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,