【发布时间】:2018-04-05 20:00:38
【问题描述】:
我想编译一些具有多个依赖 jar 的 java 文件并制作一个 jar 文件。我将所有依赖的 jar 保存在 src/main/lib 下。运行 mvn clean install 后,我得到类的编译失败。依赖的 jar 似乎没有被复制到类路径中。任何人都可以告诉她出了什么问题。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<repositories>
<repository>
<id>external-jars</id>
<name>external-jars</name>
<url>file://${project.basedir}\src\main\lib\</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>jars</groupId>
<artifactId>jars</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/lib/*</systemPath>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>finaljar</finalName>
<sourceDirectory></sourceDirectory>
</build>
</project>
【问题讨论】:
-
你创建了 pom.xml 吗?请添加你的 pom.xml
-
Maven 不喜欢存储库之外的依赖 jar。只能使用工件形式的 jar 文件!