Java 如何解决 Maven 依赖问题“无法在项目上执行目标”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22608350/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 16:49:50  来源:igfitidea点击:

How to resolve issue with Maven dependencies "Failed to execute goal on project"

javaeclipsemavenjbossjetty

提问by ruhungry

I have got the following structure in Eclipseof my maven projects:

我在Eclipse的 Maven 项目中有以下结构:

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

In Eclipse, I use JBoss 7.1to run MProject-web:

在 Eclipse 中,我使用JBoss 7.1来运行 MProject-web:

JBoss

老板

Now, I want to run Jetty with another project. From directory /MainMavenProject/MyProjectI run a command

现在,我想用另一个项目运行 Jetty。从目录/MainMavenProject/MyProject我运行一个命令

mvn -Djetty:port=8081 jetty:run

It has been finished with an error:

它已完成,但出现错误:

[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

In MyProject, I use depedencies to the other ones:

在 MyProject 中,我使用其他依赖项:

<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>

How can I check, what exactly happend and after that, how to fix it?

我如何检查,究竟发生了什么,之后如何解决?

Thank you in advance

先感谢您

采纳答案by blackbuild

Try running mvn installon the Main project first.

首先尝试mvn install在 Main 项目上运行。

Your project is missing the other modules, which likely have never been installed to local repository.

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

Not that you would have to run install every time before running jetty:run.

并不是每次运行之前都必须运行 install jetty:run

An alternative would be to use the eclipse, right click MyProject -> Run as -> Maven build..., enter -Djetty:port=8081 jetty:runin the goals field and check "Resolve workspace artifacts".

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