要打包第三方jar包,可以通过以下几种方式: 将第三方jar包手动放入项目的lib目录中,然后在pom.xml文件中使用system指定该jar包的路径,这样在打包时会将该jar包一起打包到最终的输出文件中
要打包第三方jar包,可以通过以下几种方式:
- 将第三方jar包手动放入项目的lib目录中,然后在pom.xml文件中使用system指定该jar包的路径,这样在打包时会将该jar包一起打包到最终的输出文件中。
<dependency>
<groupId>com.example</groupId>
<artifactId>example</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/example.jar</systemPath>
</dependency>
mvninstall: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>
执行mvncleanpackage
命令即可打包生成含有第三方jar包的可执行jar文件。
版权声明
本文仅代表作者观点,不代表博信信息网立场。