如何解决Maven依赖问题“在项目上执行目标失败”

4

我在 Eclipse 中有一个 Maven 项目,它的结构如下:

MainMavenProject
---MyProject
---MProject-client
---MProject-xyz
---MProject-web
...

在Eclipse中,我使用JBoss 7.1来运行MProject-web: JBoss 现在,我想要使用Jetty运行另一个项目。从目录/MainMavenProject/MyProject中,我运行了一个命令:
mvn -Djetty:port=8081 jetty:run

已完成,但出现错误:

[ERROR] Failed to execute goal on project MyProject: Could not resolve dependencies for project ***.*****.MyProject:MyProject:war:0.0.1-SNAPSHOT: The following artifacts could not be resolved: ***.*****.********:MyProject-client:jar:1.0.
1-SNAPSHOT, com.*****.********:MProject-xyz:jar:1.0.1-SNAPSHOT: Failure to find ***.*****.********:MyProject-client:jar:1.0.1-SNAPSHOT in https://*********.*****.com/nexus/content/groups/development was cached in the local repository, resolutio
n will not be reattempted until the update interval of *****-central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

在我的项目中,我使用依赖项来引用其他项目:
<dependency>
    <groupId>com.*****.********</groupId>
    <artifactId>MyProject-client/artifactId>
    <version>1.0.1-SNAPSHOT</version>
</dependency>

<dependency>
    <groupId>com.*****.********</groupId>
    <artifactId>MProject-xyz</artifactId>
    <version>1.0.1-SNAPSHOT</version>
</dependency>

我该如何检查发生了什么,并且在此之后该如何修复它?

提前感谢您。

1个回答

7

首先,尝试在主项目上运行mvn install

你的项目缺少其他模块,很可能从未安装到本地存储库中。

注意,每次运行jetty:run之前,都需要运行一次安装。

另一种方法是使用eclipse,在MyProject上右键单击 -> 运行 as -> Maven build...,在目标字段中输入-Djetty:port=8081 jetty:run并选中“解决工作区构件”。


嗨,我执行了 mvn clean 命令,但问题仍然存在。我更喜欢在命令行中使用 jetty。我能否在 Eclipse 之外运行 解决工作区构件 - ruhungry
@IWillTryToCodeIt 不行(至少不是没有一些非常卑劣的技巧)。从“主项目”执行 mvn clean install。它能工作吗? - blackbuild

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接