xml配置
加上
xmlns
schema
随便写一个类,类似如上,当执行UserDaoImpl.save(User)之前都会执行before方法。
加上
xmlns
xmlns:context="http://www.springframework.org/schema/context
schema
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class LogInterceptor {
@Before("execution(public void org.spring.dao.impl.UserDaoImpl.save(org.spring.model.User))")
public void before(){
System.out.println("method before start print");
}
}
随便写一个类,类似如上,当执行UserDaoImpl.save(User)之前都会执行before方法。