如果我想运行 spring boot 应用程序,并且想在差异路径中使用差异 application.properties(使用配置文件除外)
如何指定路径application.properties
?
如果我想运行 spring boot 应用程序,并且想在差异路径中使用差异 application.properties(使用配置文件除外)
如何指定路径application.properties
?
如果你想在不同的路径中使用不同的application.properties,使用这个命令来启动jar文件
nohup java -jar project.jar --spring.config.location=file://{file-path}/application.properties
SPRING_CONFIG_LOCATION
也可以使用环境变量。
@PropertySource 注解用于向环境提供属性文件,它与@Configuration 类一起使用。
@PropertySource({ "classpath:config.properties" })