Full-annotation development is to no longer use the spring configuration file, and write a configuration class to replace the configuration file.
package com.wsy.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* @author within
* @date 2023-02-10 12:03
*/
@Configuration
//@ComponentScan({"com.atguigu.spring6.controller", "com.atguigu.spring6.service","com.atguigu.spring6.dao"})
@ComponentScan("com.wsy")
public class Spring6Config {
}
test class
@Test
public void testAllAnnotation(){
ApplicationContext context = new AnnotationConfigApplicationContext(Spring6Config.class);
UserController userController = context.getBean("userController", UserController.class);
userController.addController();
logger.info("执行成功");
}