为什么这个切面功能执行不出来呢
@Repository//数据层
public class BookDaoImpl implements BookDao {
public void save(){
System.out.println("save"+System.currentTimeMillis());
}
public void update(){
System.out.println("update...");
}
public void delete(){
System.out.println("delete...");
}
}
-------
@Component
@Aspect
public class MyAdvice {
@Pointcut("execution(void com.example.spring.dao.BookDao.delete())")
private void pt(){}
@Before("pt()")
public void method(){
System.out.println("method");
System.out.println(System.currentTimeMillis());
}
}
-------
@Configuration
@ComponentScan("com.example.spring.dao")
@EnableAspectJAutoProxy
public class SpringConfig {
}
-------
ApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfig.class);
BookDao bookDao=ctx.getBean(BookDao.class);
bookDao.delete();
System.out.println(bookDao.getClass());
结果如图所示,哪里有问题捏