32
我想在Spring中從基於XML的配置切換到基於Java的配置。現在,我們有這樣的事情在我們的應用程序上下文:過濾@ComponentScan中的特定軟件包
<context:component-scan base-package="foo.bar">
<context:exclude-filter type="annotation" expression="o.s.s.Service"/>
</context:component-scan>
<context:component-scan base-package="foo.baz" />
但如果我寫這樣的事情...
@ComponentScan(
basePackages = {"foo.bar", "foo.baz"},
excludeFilters = @ComponentScan.Filter(
value= Service.class,
type = FilterType.ANNOTATION
)
)
...它將從都包排除服務。我有強烈的感覺,我忽略了一些令人尷尬的微不足道的事情,但我找不到解決方案將過濾器的範圍限制爲foo.bar
。
發生'Service.class'什麼:
,那麼只需在下手的情況下? – Deepen 2016-06-25 07:26:20