本文介绍了如何在maven jar构建过程中包含外部jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在maven中构建一个带有依赖项的.jar文件。不幸的是,我必须在buildpath中包含一些外部.jars。当我现在尝试使用maven包构建这个项目时,我会收到一个错误,即找不到那些外部.jars。
I want to build a .jar file with dependencies in maven. Unfortunately I have to include some external .jars in my buildpath. When I now try to build this project with maven package I will get an error that those external .jars are not found.
如何调整我的pom文件来添加这些jar ?
当前:
How to adapt my pom file to add those jars?current:
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
推荐答案
您可以在构建路径中包含外部jar作为依赖于< scope>系统< / scope>
。
You can include the external jars in your build path as dependency with <scope>system</scope>
.
检查此
这篇关于如何在maven jar构建过程中包含外部jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!