0
我使用的是java 8,spring 4.3和apsectj 1.8.9。爲什麼我得到下面的錯誤代碼如果我使用@Before(「com。 beans.Student.addCustomer()「)沒有切入點我得到這個錯誤錯誤在0找不到引用切入點。在使用@Before和poincut時,我沒有收到錯誤。春天在0的AOP錯誤找不到引用的切入點
豆類:
@Aspect
public class Beforeaspect {
/*
* @Pointcut("execution(* com.beans.Student.addCustomer(..))") public void
* log(){
* }
*/
// @Before("log()")
@Before("com.beans.Student.addCustomer()")
public void logBefore(JoinPoint jp) {
System.out.println("logbefore");
System.out.println("method " + jp.getSignature().getName());
}
}
學生:
package com.beans;
public class Student implements Studentimpl {
public void addCustomer() {
System.out.println("addcustomer");
}
public String addCustomername(String stud) {
System.out.println("addcustomername");
return "hello";
}
}
的Spring XML文件:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<aop:aspectj-autoproxy />
<bean id="stud" class="com.beans.Student" />
<bean class="com.beans.Beforeaspect" />
</beans>
感謝尼古拉,我忘了加上belowpublic類學生{ \t @Pointcut(「執行(* com.beans。 Student.addCustomers(..))「) \t空隙addCustomer(){ \t \t \t } } –