1. 程式人生 > >AOP切面程式設計(埋點選單統計)

AOP切面程式設計(埋點選單統計)

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: public final void org.mybatis.spring.support.SqlSessionDaoSupport.setSqlSessionTemplate(org.mybatis.spring.SqlSessionTemplate); nested exception is java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut pointCutName
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:599)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:92)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
... 65 more

Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut pointCutName

今天在重新複習Spring AOP的時候,使用aspectJ註解來實現Spring AOP時,用下面這種方式來獲得pointCut時報錯了:

	@Pointcut(value = "execution(* com.westsoft.kft.repairs.service.impl.*.*(..))")
	public void pointCutName() {

	}

	@Before(value = "pointCutName()")
	public void before(JoinPoint jp) {
		System.out.println("before----------" + jp.getSignature().getName());
	}

	@After(value = "pointCutName()")
	public void after(JoinPoint jp) {
		System.out.println("after-----------" + jp.getSignature().getName());
	}
}

下載下來的aspectj-1.8.1裡有4個jar包:aspectjrt.jar、aspectjtools.jar、aspectjweaver.jar和org.aspectj.matcher.jar

其餘三個我也不知道有什麼用,我只替換了其中的aspectjweaver.jar就解決了我的問題~