上網查了一下,直接在pom里面配置就好了,具體寫法如下所示
<build>
...
<resources>
<resource>
<directory>[your directory]</directory>
<includes>
<include>[resource file #1]</include>
<include>[resource file #2]</include>
<include>[resource file #3]</include>
...
<include>[resource file #n]</include>
</includes>
</resource>
...
</resources>
...
</build>
上面這段用于保留所需要的檔案
<build>
...
<resources>
<resource>
<directory>[your directory]</directory>
<excludes>
<exclude>[non-resource file #1]</exclude>
<exclude>[non-resource file #2]</exclude>
<exclude>[non-resource file #3]</exclude>
...
<exclude>[non-resource file #n]</exclude>
</excludes>
</resource>
...
</resources>
...
</build>
這一段是填寫不需要保留的檔案
include和exclude可以同時存在,exclude優先級高于include
打包時排除指定檔案就是上面這么簡單,但是打包時就會發現我了個大草,打包不了了,一看是跑單元測驗時專案無法加載了,是啊,你連組態檔都沒有還怎么加載專案,
下面給大家介紹兩個mvn命令,兩個都是跳過運行單元測驗的,大家按需使用
mvn package -DskipTests
僅跳過單元測驗,但會編譯test檔案,使用示例
mvn package -Dmaven.test.skip=true
跳過單元測驗,且不編譯test檔案
好了,現在我們可以愉快的打包了,可是我jar包里沒有組態檔怎么運行啊!!!
也就是怎么外掛組態檔
java -jar test.jar --spring.config.location=[組態檔位置]
注意,--spring.config.location引數的內容一定是檔案夾,即一定以‘/’結尾,
好了,就這么多,說的不是很詳細,沒有深入,大家有興趣可以自行搜索答案,比如springboot加載組態檔的位置順序優先級,
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/247956.html
標籤:其他
