場景
spingboot項目部署jar時,需要時常修改配置,為了方便,將配置文件放到j(luò)ar包外
操作步驟
-
在jar包同級目錄下創(chuàng)建config文件夾(位置沒有強制要求,為了方便而已)
-
在jar包同級目錄下創(chuàng)建start.bat文件,并編輯內(nèi)容文章來源:http://www.zghlxwxcb.cn/news/detail-623834.html
@echo off
:: 命令窗口標題
title yudibei_performance_test
chcp 65001
:: 用 -Dspring.config.location 指定配置文件路徑, -Dfile.encoding=utf-8 要放在-jar前面,不會控制臺中文亂碼
java -Dfile.encoding=utf-8 -jar D:\jar_test\test.jar -Dspring.config.location=D:\jar_test\config
pause
- 直接雙擊start.bat進行啟動
總結(jié)
啟動jar之前設(shè)置參數(shù) -Dspring.config.location 指向外部配置目錄即可文章來源地址http://www.zghlxwxcb.cn/news/detail-623834.html
到了這里,關(guān)于java -jar指定外部配置文件的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!