Spring boot 是否可以在外部属性文件中引用spring boot application.properties中的特定属性

Spring boot 是否可以在外部属性文件中引用spring boot application.properties中的特定属性,spring-boot,Spring Boot,在spring boot中,我有一个application.properties文件,其中有一个属性 apple=X。 我有另一个自定义属性文件custom.properties。我想在这个自定义属性文件中引用apple,所以我有: orange=${spring.apple}。 但这在运行时不起作用。 是否有任何方法可以从另一个自定义属性文件访问应用程序.properties属性 编辑: 我还尝试了orange=${apple},这也不起作用。我将spring.config.location设

在spring boot中,我有一个
application.properties
文件,其中有一个属性
apple=X
。 我有另一个自定义属性文件
custom.properties
。我想在这个自定义属性文件中引用apple,所以我有:
orange=${spring.apple}
。 但这在运行时不起作用。 是否有任何方法可以从另一个自定义属性文件访问
应用程序.properties
属性

编辑:
我还尝试了
orange=${apple}
,这也不起作用。我将
spring.config.location
设置为指向包含
application.properties
和我的
custom.properties
文件的目录。我假设spring boot将加载它在
spring.config.location
中看到的任何属性文件,但看起来它没有。
除了
application.properties
,还有什么方法可以加载我的
custom.properties
文件吗?

为什么这样做。您有一个名为
apple
的属性,并尝试通过
${spring.apple}
获取它。它基本上是查找一个名为
spring.apple
的属性,而这个属性显然不存在。只引用属性我也只引用属性,这也不起作用。那么如何加载属性文件呢?我将spring.config.location设置为指向包含application.properties和custom.properties文件的目录。spring boot似乎忽略了该目录中的其他属性文件。是的,因为默认情况下它只加载
应用程序.properties
。如何加载
自定义.properties
?请将其添加到您的问题中,而不是作为评论。