2

如果我想运行 spring boot 应用程序,并且想在差异路径中使用差异 application.properties(使用配置文件除外)

如何指定路径application.properties

4

3 回答 3

3

如果你想在不同的路径中使用不同的application.properties,使用这个命令来启动jar文件

nohup java -jar project.jar --spring.config.location=file://{file-path}/application.properties 
于 2019-04-23T06:38:16.400 回答
1

SPRING_CONFIG_LOCATION也可以使用环境变量。

https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html

于 2019-04-23T05:34:19.647 回答
0

@PropertySource 注解用于向环境提供属性文件,它与@Configuration 类一起使用。

@PropertySource({ "classpath:config.properties" })

于 2019-04-23T05:34:43.037 回答