gpt4 book ai didi

java - spring boot 向环境添加另一个属性文件

转载 作者:行者123 更新时间:2023-12-04 22:52:51 25 4
gpt4 key购买 nike

我想知道除了 application.properties 文件之外,是否可以将另一个属性文件添加到环境路径中。如果是这样,您如何指定新路径?因此,您可以使用 Autowired Environment 变量访问属性。目前在我的 java 项目中,默认属性文件 application.properties 的路径为/soctrav/src.main.resources/application.properties

最佳答案

如果您想在没有命令行参数的情况下执行此操作,则可以解决此问题。

@SpringBootApplication
@PropertySources({
@PropertySource("classpath:application.properties"),
@PropertySource("classpath:anotherbunchof.properties")
})
public class YourApplication{

}

关于java - spring boot 向环境添加另一个属性文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26935960/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com