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;
    }
}

 

你可能感兴趣的:(spring注解驱动)