来自特定属性文件的Spring配置类

时间:2020-05-10 12:25:13

标签: java spring spring-boot

假设我有一个@Configuration类,甚至还有一个@ConfigurationProperties类。

我希望从特定的application-x.properties文件中加载配置。

我该怎么做? (无需定义新的Spring配置文件)

1 个答案:

答案 0 :(得分:1)

您必须使用@PropertySources,例如:@PropertySource("classpath:foo.properties")

选中此项可获得更多信息,并查看其他选项。 https://www.baeldung.com/properties-with-spring