要打包第三方jar包,可以通過以下幾種方式:
<dependency>
<groupId>com.example</groupId>
<artifactId>example</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/example.jar</systemPath>
</dependency>
mvn install:install-file -Dfile=path/to/example.jar -DgroupId=com.example -DartifactId=example -Dversion=1.0 -Dpackaging=jar
<dependency>
<groupId>com.example</groupId>
<artifactId>example</artifactId>
<version>1.0</version>
</dependency>
在pom.xml文件中配置assembly插件:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.example.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
執行mvn clean package
命令即可打包生成含有第三方jar包的可執行jar文件。