我正在执行一个 jar 并在 args 中传递一个属性文件
java - jar file.jar props.properties
为了读取属性文件,我使用了java.util.Properties.load
。我想知道是否有更好的方法来使用 Spring Boot 来做到这一点,因为属性文件可以存在于不同的位置或具有不同的名称,但始终具有相同的属性。
我尝试使用PropertySource
,但找不到动态设置属性文件的方法
最佳答案
您可以使用:
java -jar app.jar --spring.config.location=file:///Users/home/config/jdbc.properties
更多信息请点击:https://www.baeldung.com/spring-properties-file-outside-jar
关于java - 使用 Spring Boot 加载外部文件属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57600233/