我有一个maven项目设置。
在我的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>
我有一个父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>
当我跑步时
mvn clean install
resteasy-jaxrs和resteasy-spring会毫无问题地下载到我的本地存储库。
然而,它产生了一个错误说:
**[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]**
看起来项目无法获取本地存储库中已存在的依赖项。
有人能让我知道如何解决这个问题吗?
非常感谢
更多信息:
我暂时删除了依赖项com.myProject.shared。现在错误消息变为:
[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]
答案 0 :(得分:12)
好吧,看起来禁止访问。
您需要使用JBoss存储库的正确路径:https://repository.jboss.org/nexus/content/groups/public-jboss/
这是您需要的神器: https://repository.jboss.org/nexus/content/groups/public-jboss/org/scannotation/scannotation/
所以,请在你的POM中提及:
<repository>
<id>JBoss</id>
<name>JBoss</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</repository>
在存储库列表中
答案 1 :(得分:6)
mvn clean install
您的model
项目首先。这会将其工件安装到您的目标构建可以找到它们的本地仓库中。
如果这仍然无效,请使用-X
开关显示更多错误/调试信息:
mvn -X clean install
答案 2 :(得分:0)
只看你的错误输出(我假设你没有手动输入),你似乎错误地将myProject中的组ID输入到mxProject。
答案 3 :(得分:0)
双重检查依赖声明(artifactId和groupId),它可能只是一个错字;)