从docs和example看看是不是清楚的类路径操作是不允许的。
<configuration>
<compilerArgs>
<arg>classpath=${basedir}/lib/bad.jar</arg>
</compilerArgs>
</configuration>
但见Java docs(也https://www.cis.upenn.edu/~bcpierce/courses/629/jdkdocs/tooldocs/solaris/javac.html)
-classpath path指定的javac用来查找到运行javac或其他类中引用所需的类你 编译。如果已设置,则覆盖默认或CLASSPATH环境变量 。
也许有可能获得当前classpath和扩展它,
看到in maven, how output the classpath being used?
<properties>
<cpfile>cp.txt</cpfile>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>build-classpath</id>
<phase>generate-sources</phase>
<goals>
<goal>build-classpath</goal>
</goals>
<configuration>
<outputFile>${cpfile}</outputFile>
</configuration>
</execution>
</executions>
</plugin>
读取文件(Read a file into a Maven property)
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
def file = new File(project.properties.cpfile)
project.properties.cp = file.getText()
</source>
</configuration>
</execution>
</executions>
</plugin>
最后
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<compilerArgs>
<arg>classpath=${cp}:${basedir}/lib/bad.jar</arg>
</compilerArgs>
</configuration>
</plugin>
这个罐子是否需要在那个位置?或者您是否需要一种方法来包含本地罐子? – Gamlor 2010-08-04 23:13:45
重复的[Maven,如何添加额外的库不可用在回购](http://stackoverflow.com/questions/2479046/maven-how-to-add-additional-libs-not-available-in-repo), [Maven的。如何处理“无家可归”的罐子?](http://stackoverflow.com/questions/2916949/maven-what-to-do-with-homeless-jars),[本地罐子不包括在类路径中](http ://stackoverflow.com/questions/3280834/local-jars-are-not-included-in-class-path/3281409#3281409)等等。 – 2010-08-05 10:39:53
您是否找到添加目录的方法?而不是在classpath中添加每个jar文件? – SJunejo 2016-08-03 02:05:12