[英]Maven project cannot locate dependencies in local repository
I have a maven project setup. 我有一个maven项目设置。
In my maven POM file, it is defined as below: 在我的maven POM文件中,它定义如下:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>com.myProject</groupId>
<artifactId>basePOM</artifactId>
<version>1.0</version>
<relativePath>../../../shared/common/pom.xml</relativePath>
</parent>
<groupId>com.myProject.services</groupId>
<artifactId>orderservice</artifactId>
<version>developer</version>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!--Internal dependencies-->
<dependency>
<groupId>com.myProject.shared</groupId>
<artifactId>model</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-spring</artifactId>
</dependency>
</dependencies>
</project>
I have a parent POM which defines some common bits: 我有一个父POM定义了一些常见的位:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<name>Base POM</name>
<groupId>com.myProject</groupId>
<artifactId>basePOM</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.myProject.shared</groupId>
<artifactId>model</artifactId>
<version>developer</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>1.2.GA</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-spring</artifactId>
<version>1.2.GA</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
When I run 我跑的时候
mvn clean install
The resteasy-jaxrs and resteasy-spring are downloaded to my local repository without problem. resteasy-jaxrs和resteasy-spring会毫无问题地下载到我的本地存储库。
However, it then produces an error said: 然而,它然后产生一个错误说:
**[ERROR] Failed to execute goal on project orderservice: Could not resolve dependencies for
project com.mxyy.services:orderservice:war:developer: Failed to collect dependencies for
[com.mxyy.shared:model:jar:developer (compile), org.jboss.resteasy:resteasy-jaxrs:jar:1.2.
GA (compile), org.jboss.resteasy:resteasy-spring:jar:1.2.GA (compile), org.testng:testng:j
ar:jdk15:5.8 (test)]: Failed to read artifact descriptor for com.mxyy.shared:model:jar:dev
eloper: Failure to find com.mxyy:basePOM:pom:1.0 in http://repo.maven.apache.org/maven2 wa
s cached in the local repository, resolution will not be reattempted until the update inte
rval of central has elapsed or updates are forced -> [Help 1]**
It looks like the project cannot pickup the dependencies already in my local repository. 看起来项目无法获取本地存储库中已有的依赖项。
Can someone let me know how I can solve this problem? 有人能让我知道如何解决这个问题吗?
Many thanks 非常感谢
More Info: 更多信息:
I have temporarily removed the dependency com.myProject.shared. 我暂时删除了依赖项com.myProject.shared。 Now the error message becomes: 现在错误消息变为:
[ERROR] Failed to execute goal on project orderservice: Could not resolve dependencies for project com.mxyy.services:orderservice:war:developer: Faile
d to collect dependencies for [org.jboss.resteasy:resteasy-jaxrs:jar:1.2.GA (compile), org.jboss.resteasy:resteasy-spring:jar:1.2.GA (compile)]: Faile
d to read artifact descriptor for org.scannotation:scannotation:jar:1.0.2: Could not transfer artifact org.scannotation:scannotation:pom:1.0.2 from/to
jboss (http://repository.jboss.org/maven2): Access denied to: http://repository.jboss.org/maven2/org/scannotation/scannotation/1.0.2/scannotation-1.0
.2.pom, ReasonPhrase:Forbidden. -> [Help 1]
Well, looks like the access is forbidden. 好吧,看起来禁止访问。
You need to use the right path to JBoss repository: https://repository.jboss.org/nexus/content/groups/public-jboss/ 您需要使用正确的 JBoss存储库路径: https : //repository.jboss.org/nexus/content/groups/public-jboss/
Here is the artifact you need: https://repository.jboss.org/nexus/content/groups/public-jboss/org/scannotation/scannotation/ 这是您需要的工件: https : //repository.jboss.org/nexus/content/groups/public-jboss/org/scannotation/scannotation/
So, mention in your POM: 那么,请在您的POM中提及:
<repository>
<id>JBoss</id>
<name>JBoss</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</repository>
in repositories list 在存储库列表中
mvn clean install
your model
project first . mvn clean install
的model
的第一个项目。 That will install its artifacts into your local repo where your target build can find them. 这会将其工件安装到您的目标构建可以找到它们的本地仓库中。
If this still does not help, use the -X
switch to display more error/debug information: 如果仍然没有帮助,请使用-X
开关显示更多错误/调试信息:
mvn -X clean install
双重检查依赖声明(artifactId和groupId),它可能只是一个错字;)
只看你的错误输出(我假设你没有手动输入),你似乎错误地将组ID从myProject输入到mxProject。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.