spring注解驱动开发基本包扫描配置

更加全面的spring注解配置可以参看spring官方文档,有所有的注解以及对应的配置文件的配置 

https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html

@ComponentScan(value = "com.annotation",useDefaultFilters = false,includeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class,ControllerAdvice.class})})
@Configuration
public class MainConfig {

    @Bean(name = "person")
    public Person person(){
        Person person = new Person();
        person.setId(1);
        person.setName("lqf");
        person.setEmail("[email protected]");
        return person;
    }
}

猜你喜欢

转载自blog.csdn.net/qq_36722039/article/details/81572220