原本在这,我这里不像写xml配置文件,所以这里我们用完全注解开发。
https://blog.csdn.net/qq_42388853/article/details/108311490
这里需要改的只有配置文件xml换成java文件:
package cn.zsp.spring5.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@Configuration
@ComponentScan(basePackages = {"cn.zsp"})
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class ConfigAop {
}
测试类变成了这样
@Test
public void test2(){
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConfigAop.class);
User user = context.getBean("user", User.class);
user.add();
}