版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/T1014216852/article/details/83895328
因为需要用到腾讯云的一些服务,所以得使用腾讯云的加密工具的 jar。但是这些 jar 只能通过本地进行引用、打包、部署。
首先说,我的项目是 maven 分模块的,某一个子模块需要用到这些本地 jar。
我使用的是 Spring-boot-plugin 3.7.0 。
子模块的 pom.xml 显示:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
下面是我的本地 jar 包导入操作:
1. 在需要使用的模块下建一个 lib 文件夹,然后然后将本地 jar 放进去
2. 通过下面的 maven dependency 导入
<dependency>
<groupId>gson-2.3.1</groupId>
<artifactId>gson-2.3.1</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>
${basedir}/lib/gson-2.3.1.jar
</systemPath>
</dependency>
groupId 和 artifactId 可以根据 jar 包名来写。然后 <scope> 写的是 system。系统路径的使用 ${basedir} 来确定决定路径。(看到网上有些文章是使用 ${project.baseUrl} ,但是我试了不成功。)
总结一下步骤:
1. 开特定的文件夹,让 maven 能够找到 jar
2. 使用 maven 找到本地 jar 包,并进行解析和导入