【问题标题】:How to exclude spring configuration files with @Configuration for dependency on other project如何使用 @Configuration 排除 spring 配置文件以依赖于其他项目
【发布时间】:2017-05-30 06:41:51
【问题描述】:

我有一个项目说 A[In Maven],它依赖于项目 B[In Maven]。现在项目 B 得到了一些 spring @Configuration[db configuration] 文件,当我构建和部署项目 A 时会启动这些文件,但是由于我的项目 A 中没有一些配置属性,它显示了一些错误。那么如何在项目 B 中使用其他依赖项时排除项目 A 中的配置文件。

【问题讨论】:

    标签: spring dependency-injection maven-3


    【解决方案1】:

    您可以在组件扫描中添加 excludeFilters 以跳过该类

    @ComponentScan(value = {'your.package.here'}, excludeFilters = @Filter(ConfigurationToIgnore.class))
    

    【讨论】:

    • 我能有等价的 .xml 配置吗
    • <context:component-scan base-package="your.package.here" />
    • 好的,找到一个
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-28
    • 2014-05-05
    • 2020-08-17
    • 2016-01-13
    • 1970-01-01
    • 2020-01-07
    • 2011-03-16
    相关资源
    最近更新 更多