即使存在build-info.properties,带有ConditionalOnMissingBean的BuildProperties Bean始终会覆盖BuildProperties

时间:2018-10-26 03:05:13

标签: java spring spring-boot

我有以下bean声明

@Bean
@ConditionalOnMissingBean(value = BuildProperties.class)
public BuildProperties buildProperties() {
    Properties properties = new Properties();
    properties.setProperty("artifact", "app");
    properties.setProperty("group", "com.example");
    properties.setProperty("name", "app");
    properties.setProperty("version", "SNAPSHOT");
    properties.setProperty("time", Instant.now().toString());
    return new BuildProperties(properties);
}

我只希望当build-info.properties中的BuildProperties bean不存在时(即从IDE而不是从build运行)实例化该bean

但是,似乎总是实例化此bean,并且从未拾取build-info.properties中的BuildProperties。

这里似乎是什么问题?

0 个答案:

没有答案