Springboot導入本地jar后 打包依賴無法加入
1.本地jar包
2.pom文件添加自定義jar包導入
1
2
3
4
5
6
7
8
|
<!--自定義jar--> < dependency > < groupId >epublib-core</ groupId > < artifactId >1.0</ artifactId > < scope >system</ scope > < systemPath >${project.basedir}/lib/epublib-core-latest.jar</ systemPath > < version >1.0.0</ version > </ dependency > |
3.添加
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
< build > < plugins > < plugin > < groupId >org.apache.maven.plugins</ groupId > < artifactId >maven-compiler-plugin</ artifactId > </ plugin > < plugin > < groupId >org.springframework.boot</ groupId > < artifactId >spring-boot-maven-plugin</ artifactId > </ plugin > </ plugins > < resources > < resource > < filtering >true</ filtering > < directory >${basedir}/src/main/resources</ directory > < includes > < include >**/bootstrap*.yml</ include > <!--這三個我本地配置文件,具體配置根據需求修改--> < include >**/bootstrap*.yaml</ include > < include >**/bootstrap*.properties</ include > </ includes > </ resource > < resource > < directory >${basedir}/src/main/resources</ directory > < excludes > < exclude >**/bootstrap*.yml</ exclude > <!--這三個我本地配置文件,具體配置根據需求修改--> < exclude >**/bootstrap*.yaml</ exclude > < exclude >**/bootstrap*.properties</ exclude > </ excludes > </ resource > < resource > < directory >${basedir}/lib</ directory > < targetPath >BOOT-INF/lib/</ targetPath > < includes > < include >**/*.jar</ include > </ includes > </ resource > </ resources > </ build > |
項目引入本地jar包,并設置maven打包一并打入
resources目錄下新建lib文件夾,然后將需要的本地jar包放入進去
pom文件中引入本地jar包依賴
1
2
3
4
5
6
7
|
< dependency > < groupId >com.XXX</ groupId > < artifactId >XXXXX</ artifactId > < version >0.0.1-SNAPSHOT</ version > < scope >system</ scope > < systemPath >${project.basedir}/src/main/resources/lib/XXXXX.jar</ systemPath > </ dependency > |
在springboot的maven工具增加includeSystemScope功能
作用:打包時將scope為system的jar包一并打入包內
1
2
3
4
5
6
7
8
|
< plugin > < groupId >org.springframework.boot</ groupId > < artifactId >spring-boot-maven-plugin</ artifactId > <!-- 作用:項目打成jar的同時將本地jar包也引入進去 --> < configuration > < includeSystemScope >true</ includeSystemScope > </ configuration > </ plugin > |
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持服務器之家。
原文鏈接:https://blog.csdn.net/zhangshengqiang168/article/details/94467364