SpringBoot 外部配置文件
Siona
SpringBoot 外部配置文件
一、使用 config
文件夹

# 启动命令
nohup java -jar xxx-api.jar > /dev/null &
# 通过指定 spring.profiles.active 参数来切换配置文件
nohup java -jar xxx-api.jar --spring.profiles.active=prod > /dev/null &
Application properties 文件
Spring 应用程序从以下几个位置加载 application.properties
文件,并将它们添加到 Spring 环境:
- 当前目录的子目录
/config
中 - 当前目录
- classpath 中的 package 包
/config
- classpath 根路径