Spring全注解开发
全注解开发就是不再使用spring配置文件了,写一个配置类来代替配置文件。
package com.atguigu.spring6.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
//@ComponentScan({"com.atguigu.spring6.controller", "com.atguigu.spring6.service","com.atguigu.spring6.dao"})
@ComponentScan("com.atguigu.spring6")
public class Spring6Config {
}
测试类
@Test
public void testAllAnnotation(){
//加载配置类
ApplicationContext context = new AnnotationConfigApplicationContext(Spring6Config.class);
UserController userController = context.getBean("userController", UserController.class);
userController.out();
logger.info("执行成功");
}
标签:Spring15,开发,com,context,atguigu,注解,userController,spring6
From: https://www.cnblogs.com/Ashen-/p/17095883.html