金昌市网站建设_网站建设公司_网站建设_seo优化
2025/12/25 22:03:33 网站建设 项目流程

就是编写一个类,在这个类上面使用大量注解来代替spring的配置文件,spring配置文件消失了,如下:

packagecom.powernode.spring6.service;importorg.springframework.context.annotation.ComponentScan;importorg.springframework.context.annotation.Configuration;importorg.springframework.context.annotation.EnableAspectJAutoProxy;@Configuration@ComponentScan("com.powernode.spring6.service")@EnableAspectJAutoProxy(proxyTargetClass=true)publicclassSpring6Configuration{}

测试程序也变化了:

@TestpublicvoidtestAOPWithAllAnnotation(){ApplicationContextapplicationContext=newAnnotationConfigApplicationContext(Spring6Configuration.class);OrderServiceorderService=applicationContext.getBean("orderService",OrderService.class);orderService.generate();}

执行结果如下:

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询