springAOP配置XML方式配置切面报错error at ::0 formal unbound in pointcut

时间:2023-12-21 09:23:02

【错误配置文件】

  <aop:config>
<aop:pointcut expression="execution(* net.fifteenho.service.impl.UserServiceImpl.*(..))" id="mypc"/>
<aop:advisor advice-ref="tx" pointcut-ref="mypc"/>
<aop:aspect ref="myException">
<aop:after-throwing method="exception" pointcut-ref="mypc"/><!--缺少throwing属性赋值-->
</aop:aspect>
</aop:config>

【正确配置文件】

  <aop:config>
<aop:pointcut expression="execution(* net.fifteenho.service.impl.UserServiceImpl.*(..))" id="mypc"/>
<aop:advisor advice-ref="tx" pointcut-ref="mypc"/>
<aop:aspect ref="myException">
<aop:after-throwing method="exception" throwing="e" pointcut-ref="mypc"/><!--throwing属性值必须与此切面类的exception方法的参数名称一致-->
</aop:aspect>
</aop:config>