SpringMVC-Controller加载控制与业务bean加载控制

推荐先阅读Spring全家桶

SpringMVC相关bean(表现层bean),也就是controller包下的类

Spring控制的bean

  • 业务bean(Service)
  • 功能bean(DataSource,SqlSessionFactoryBean,MapperScannerConfigurer等)

@ComponentScan

@Configuration
@ComponentScan(value="com.zx",
excludeFilters=@ComponentScan.Filter(
type = FilterType.ANNOTATION,
classes = Controller.class
)
)
public class SpringConfig {
}
  • excludeFilters:排除扫描路径中加载的bean,需要指定类型(type)与具体项(classes)

  • includeFilters:加载指定的bean,需要指定类别(type)与具体项(classes)