我想配置 Spring
在生产过程中覆盖某些属性,但只有(!)如果找到 development.properties
文件,并且仅适用于它的属性定义。但这些限制应该只适用于这个生产文件。应该需要所有其他属性文件。
但是我无法在 spring 配置中导入两个不同的属性资源。我需要改变什么?
@Configuration
@PropertySource({"classpath:default.properties"})
@PropertySource({"file:production.properties"}, ignoreResourceNotFound = true) //Error: Duplicate annotation
最佳答案
尝试使用 PropertySources
注解,它是一个聚合了多个 PropertySource
注解的容器注解。
关于java - 如何在 Spring 配置中导入可选属性文件以进行生产?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22784577/