依赖本地jar包
<dependency>
<groupId>org.example</groupId>
<artifactId>mydependency</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/xxx.jar</systemPath>
</dependency>
方法一
将本地jar包安装到本地仓库里,使用maven打包插件,即可将本地jar包打包进项目的整体jar包内
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>主启动类</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
方法二
引入springboot,比如当前工程有个lib目录,lib目录下有很多本地jar包
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>2.1.9.RELEASE</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.9.RELEASE</version>
<configuration>
<includeSystemScope>true</includeSystemScope>
<mainClass>org.example.function.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
这种方式也可以将本地依赖打包进项目里
- 这种方式可能打包出来的jar包稍微有点大