我想完全外化我的配置文件,以便每个* .properties文件位于/ etc/foo /中。Springboot @PropertySource with --spring.config.location =/etc/foo/
但我不希望一切都在一个大的application.properties中,因此我将某些部分拆分为单独的* .properties文件。
我怎么能告诉@PropertySource,它应该可以解决给定的属性文件,正是因为它会做它的application.properties,即在每一个直接搜索它,我用“指定(可以是多个)的位置 - spring.config.location“?
我班在理想情况下这样看:
@Configuration
@PropertySource("dpuProfiles.properties")
@ConfigurationProperties("dpu.profiles")
public class DpuProfilesConfiguration {
...
}
它的工作,如果我明确指定“文件:/etc/foo/dpuProfiles.properties”。 我无法通过EL工作获得“$ {spring.config.location} /dpuProfiles.properties”或类似的替换。由于该变量可能包含多个目录,因此可能无意义。
使用/ etc/foo作为classpath目录是个好主意。 我的@ConfigurationProperites是正确的,因为它获取属性名称前缀而不是文件名作为参数。 此外,我在/ pom.xml中将/ etc/foo添加到我的中,以便“mvn test”仍能找到它们。 –
lathspell