Spring中的完全注解开发
作者:互联网
完全注解开发
(1)创建配置类,替代 xml 配置文件 @Configuration //作为配置类,替代 xml 配置文件 @ComponentScan (basePackages = { "com.tansun" }) public class SpringConfig { } (2)编写测试类 @Test public void testService2() { //加载配置类 ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig. class ); UserService userService = context.getBean( "userService" , UserService. class ); System. out .println(userService); userService.add(); }标签:xml,配置文件,Spring,开发,注解,userService,SpringConfig,class,UserService 来源: https://blog.csdn.net/weixin_43882788/article/details/122419107