Maven:将文件夹或jar文件添加到当前类路径中

Dav*_*vid 18 maven-2 jar classpath

我正在使用maven-compile插件来编译类.现在我想在当前的类路径中添加一个jar文件.该文件保留在另一个位置(假设c:/jars/abc.jar.我更喜欢将此文件保留在此处).我怎样才能做到这一点?

如果我在参数中使用classpath:

<configuration>
 <compilerArguments>
  <classpath>c:/jars/abc.jar</classpath>
 </compilerArguments>
</configuration>
Run Code Online (Sandbox Code Playgroud)

它将无法工作,因为它将覆盖当前的类路径(包括所有依赖项)

请帮我.

mic*_*hid 9

这可能是之前被问过的.请参阅我可以将jar添加到maven 2构建类路径而不安装它们吗?

简而言之:将jar包含为系统范围的依赖项.这需要指定jar的绝对路径.

另见http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

  • 我想知道人们何时会停止建议滥用`system`范围请参阅Brian的[答案](http://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without -installing-they/764684#764684)在您链接的问题中.另见[此前一个答案](http://stackoverflow.com/questions/3280834/local-jars-are-not-included-in-class-path/3281409#3281409). (11认同)