所以我试图将两个本地jar文件包含到我有的Maven项目中,但没有这样做。我尝试了解这些线程中的解决方案:12但它仍然没有工作。这里是我的pom.xml文件的关键部分:在maven项目中包含本地jar文件 - 找不到文件
<repository>
<id>local-maven-repo</id>
<url>file://${basedir}/resources</url>
</repository>
然后依存关系:
<dependency>
<groupId>edu.mlab.jar1</groupId>
<artifactId>jar1_local</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>edu.mlab.jar2</groupId>
<artifactId>jar2_local</artifactId>
<version>1.0</version>
</dependency>
两个jar文件包括包声明在edu.mlab.jar1
和edu.mlab.jar2
分别,因此,这就是我想要他们。 jar文件位于资源文件夹中,正好位于基本目录下。
这就是设置。现在,当我尝试mvn package
(后mvn clean
)我收到以下错误
[ERROR] Failed to execute goal on project PROJECT: Could not resolve dependencies for project edu.mlab.project:PROJECT:war:1.0-SNAPSHOT: The following artifacts could not be resolved: edu.mlab.jar1:jar1_local:jar:1.0, edu.mlab.jar2:jar2_local:jar:1.0: Failure to find edu.mlab.jar1:jar1_local:jar:1.0 in file:///Users/mlab/Desktop/2016/project_web/resources was cached in the local repository, resolution will not be reattempted until the update interval of local-maven-repo has elapsed or updates are forced -> [Help 1]
我真的不知道发生了什么错误看到,因为我jar1和jar2正是在资源文件夹中。另外,我已经尝试了将它们与系统范围一起导入的方法,但这不适合我的目的,因为我希望它们包含在战争工件中。
非常感谢!
你有文件在这里file:///Users/mlab/Desktop/2016/project_web/resources/edu/mlab/jar1/jar1_local/jar1_local-1.0.jar? – davidxxx
不,我不这样做,但是不是包装宣言应该照顾的吗? –
我重新编辑了路径。不,Maven search jar在groupId/artifactId/artifactId-version.jar中,其中必须将每个点字符的目录拆分为groupid。 试试:) – davidxxx