这里需要改的只有配置文件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 = {"com.atguigu"})
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class ConfigAop {
}
测试类:
@Test
public void test3(){
AnnotationConfigApplicationContext configApplicationContext = new AnnotationConfigApplicationContext(configDemo.class);
User bean = configApplicationContext.getBean(User.class);
bean.add();
}
文件的位置为: