IDE开发工具启动 在JetBrains idea开发工具的配置 1.启动类启动方式 2.main方法启动方式 在IDEA中的program arguments配置此项--spring.profiles.active=dev命令 3.
在IDEA中的program arguments配置此项--spring.profiles.active=dev
命令
在IDEA中的VM options配置此项-Dspring.profiles.active=dev
命令
nohup java -jar -Dfile.encoding=utf-8 -Dspring.profiles.active=dev example.jar >/dev/null 2>&1 &
该启动时方式会去加载Jar包中resource目录下application-dev.yml或application-dev.properties文件。同时需要注意的是通IDEA的启动方式一样。
yml文件
nohup java -jar -Dfile.encoding=utf-8 -Dspring.config.location=classpath:/application-dev.yml example.jar >/dev/null 2>&1 &
properties文件
nohup java -jar -Dfile.encoding=utf-8 -Dspring.config.location=classpath:/application-dev.properties example.jar >/dev/null 2>&1 &
若配置文件在Jar包外面,-Dspring.config.location=后面不用classpath,直接使用配置文件的相对或绝对路径即可:
例如 -Dspring.config.location=app-dev.yml
-Dspring.config.location=/usr/local/soft/config/app-dev.yml
来源地址:https://blog.csdn.net/m0_54255522/article/details/129858734
--结束END--
本文标题: springboot项目(jar包)指定配置文件启动
本文链接: https://www.lsjlt.com/news/376515.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-03
2024-04-03
2024-04-01
2024-01-21
2024-01-21
2024-01-21
2024-01-21
2023-12-23
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0