Spring6-full annotation development

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("执行成功");
    }

Guess you like

Origin blog.csdn.net/qq_41264674/article/details/128969324