Pun*_*cky 1 java spring spring-boot
如果我在软件包com.xyz.abc中有大约50个spring bean,并且我想要排除其中2个bean被视为bean,那么有办法吗?我正在使用Spring Boot.
@ComponentScan({'com.xyz.abc'})
Run Code Online (Sandbox Code Playgroud)
有一个类Automobile.class,我不想被视为Spring Bean.但是我有Car.class延伸汽车被视为春豆.
您可以excludeFilters使用@ComponentScan注释的参数将特定类排除在扫描到bean之外.
这允许排除特定类,匹配给定模式的类......
例如,要排除firstClass,secondClass你会写:
@ComponentScan(value = {'com.xyz.abc'}, excludeFilters = {
@ComponentScan.Filter(classes = { firstClass.class, secondClass.class })
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4606 次 |
| 最近记录: |