maven引入本地jar包的方法

示例

引入达梦的数据库驱动

操作

1.引入 jar 到目录

image-20221117135856140

pom.xml 中引入

1
2
3
4
5
6
7
<dependency>
<groupId>com.dameng</groupId>
<artifactId>database</artifactId>
<version>18.0</version>
<scope>system</scope>
<systemPath>${pom.basedir}/libs/DmJdbcDriver18.jar</systemPath>
</dependency>
  • groupId:自定义
  • artifactId:自定义
  • version:自定义
  • scope:必须是 system
  • systemPath:jar 包的路径

打包引入本地包

在 pom.xml 中配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
<plugins>
<build>

主要是<includeSystemScope>true</includeSystemScope> 这个。

然后使用 idea 的 maven package 就可以了。


maven引入本地jar包的方法
https://cuifuan.github.io/2023/03/01/back-end/maven-local-jar-import/
作者
cuifuan
发布于
2023年3月1日
许可协议