这是applicationContext.xml AOP部分:
<bean id="logHandler" class="demo.anderson.aop.LogHandler"></bean>
<aop:config>
<aop:aspect id="log" ref="logHandler">
<aop:pointcut id="addLog" expression="execution(* demo.anderson.controller.StudentController.*(..)) || execution(* demo.anderson.controller.ScoreController.*(..))" />
<aop:before method="beforeLog" pointcut-ref="addLog" />
<aop:after method="afterLog" pointcut-ref="addLog" />
</aop:aspect>
</aop:config>起作用了!
但是,当我像这样配置aop:切入点时:
<aop:pointcut id="addLog" expression="execution(* demo.anderson.controller.*.*(..))" />它坏了:
18-2017年7月11:06:39.416 org.apache.catalina.core.StandardContext.listenerStart嚴重http-nio-8090-exec-71异常发送上下文初始化事件到类的侦听器实例org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException:错误创建bean的名称'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0':初始化失败;嵌套异常是org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$Match .............................................................的java.lang.IllegalStateException:预期的原始类型形式由: org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$Match .............................................................的预期原始类型形式java.lang.IllegalStateException引起 2017年7月18日11:06:39.434 org.apache.catalina.core.ApplicationContext.log資訊http-nio-8090-exec-71資訊
谁能告诉我原因吗?正确的配置是什么?
发布于 2017-07-18 06:49:52
<aop:pointcut id="addLog" expression="execution(* demo.anderson.controller..*.*(..))" /> 引用自春季文档。
https://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html
在服务包或子包中定义的任何方法的执行:
执行(* com.xyz.service..*.*(..)) )
https://stackoverflow.com/questions/45156991
复制相似问题