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