问题
在使用 maven 项目的时候,我们会引入很多的第三方 jar 包,其中有一些不在我们自己的私服或者中央仓库
中,比如我们本地的 jar 包
解决方式
第一步,在项目结构中新建一个存放本地 jar 包的文件夹,将本地 jar 包放到文件夹下,如下图所示:
第二步,在 pom 文件中引入 libs 文件夹下面的 jar 包;
1 <dependency> 2 <groupId>com.kxl</groupId> 3 <artifactId>kxl-invoice-sdk</artifactId> 4 <version>1.0-SNAPSHOT</version> 5 <scope>system</scope> 6 <systemPath>${project.basedir}/libs/kxl-invoice-sdk-1.0.jar</systemPath> 7 </dependency>
第三步,在 pom 文件的打包插件中增加打包时将本地 jar 包打到 部署的 jar包中去;
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.5.6.RELEASE</version> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin>
<includeSystemScope>true</includeSystemScope> 的作用就是在打包的时候将 jar 包 打进我们的 可启动 jar 包中;