简体   繁体   English

如何修复Eclipse中的Maven,Maven配置和Maven依赖问题

[英]How to fix Maven, Maven Configuration and Maven Dependency Problems in Eclipse

Edit: I have not resolved this problem yet but this post could be really useful in this kind of problems: 编辑:我还没有解决这个问题,但这篇文章在这类问题上真的很有用:

How to fix your Maven problems 如何解决你的Maven问题


I did svn checkout of my maven project to directory MainDirectory. 我把我的maven项目的svn签出到目录MainDirectory。 Everything went well. 一切顺利。

Next, I went to MainDirectory and I run command 接下来,我去了MainDirectory并运行命令

mvn clean package mvn清洁包

with BUILD SUCCESS BUILD SUCCESS

I went to directory of my project MainDirectory/MyProject and I run the same command, once again it worked well. 我去了我的项目MainDirectory / MyProject的目录,我运行相同的命令,再次运行良好。

I run Eclipse and I wanted to import " Existing Maven Projects ". 我运行Eclipse,我想导入“ 现有Maven项目 ”。 I chose MainDirectory as RootDirectory and I got a warning: 我选择MainDirectory作为RootDirectory,我得到一个警告:

警告

I clicked next and I saw few errors: 我点击下一步,我看到几个错误:

错误

Anyhow, I clicked finish (because of Action: Resolve Later ) 无论如何,我点击完成(因为动作:稍后解决

I was waiting few seconds and I saw this error: 我等了几秒钟,我看到了这个错误:

误差2

but my projects are visible in Project Explorer. 但我的项目在Project Explorer中可见。

I was carrying on. 我继续。 I imported second " Existing Maven Projects " - MainDirectory/MyProject. 我导入了第二个“ 现有Maven项目 ” - MainDirectory / MyProject。 This time, I had no warning. 这一次,我没有任何警告。 I clicked next and errors appeared: 我点击下一步,出现错误:

误差3

I clicked finish and another error appeared: 我点击完成并出现另一个错误:

Error4

Anyhow, new project exists now in Project Explorer. 无论如何,Project Explorer中现在存在新项目。

I went to Project->Clean and I chose all my projects. 我去了Project-> Clean ,我选择了所有的项目。 Once again I got an error: 我再次收到一个错误:

Error5

Finally, I tried Maven->Update Project and another error appeared: 最后,我尝试了Maven-> Update Project ,出现了另一个错误:

Error6

I was trying to clean somehow my local repo but I am not sure if I did it correctly. 我试图以某种方式清理我的本地回购,但我不确定我是否正确做到了。

Finally in Eclipse I see errors as below: 最后在Eclipse中我看到如下错误:

在此输入图像描述

In fact, I have already done this procedure once few days ago and everything worked perfectly. 事实上,我几天前已经完成了这个程序,一切都很完美。

When I run my application: 当我运行我的应用程序时:

mvn jetty:run

It works perfectly. 它完美地运作。

Thank you in advance 先感谢您

I have already got this problem, please make sure that the configuration file path of maven is correctly set in your eclipse ? 我已经遇到了这个问题,请确保在eclipse中正确设置了maven的配置文件路径? If you install maven by yourself it is setting with a default path which might not be the same as yours. 如果您自己安装maven,则设置的默认路径可能与您的路径不同。

Check the following screen to check if you have the good settings, to go here just go to window->preference and type maven in the type filter : 检查以下屏幕以检查您是否具有良好的设置,转到此处只需转到window-> preference并在类型过滤器中键入maven:

Maven设置

There may be following solutions- 可能有以下解决方案 -

  1. Convert project into maven project(if maven nature is not there in project configuration) 将项目转换为maven项目(如果项目配置中没有maven性质)
  2. Check Maven Dependency Library in Build Path. 检查构建路径中的Maven依赖库。 None of the dependency should throw error. 没有依赖项应该抛出错误。

If problem still persist then- 如果问题仍然存在,那么 -

  1. Open terminal, goto the project folder where pom.xml is present and run mvn eclipse:eclipse command in terminal and refresh the project in eclipse. 打开终端,转到存在pom.xml的项目文件夹,在终端运行mvn eclipse:eclipse命令,在eclipse中刷新项目。

  2. run mvn clean install to install jar in local repo(.m2) (run mvn clean install -Dmaven.test.skip=true if you want to skip test cases.) 运行mvn clean install以在本地存储库中安装jar(.m2)(如果要跳过测试用例, mvn clean install -Dmaven.test.skip=true运行mvn clean install -Dmaven.test.skip=true 。)

It should definitely work. 它应该肯定有用。

Another Stackoverflow user was having a similar problem and there are several things to try listed as answers to that question. 另一个Stackoverflow用户遇到了类似的问题,有几件事要尝试列出作为该问题的答案。 Do any of the workarounds outlined on that question help you? 这个问题上列出的任何变通方法对您有帮助吗?

Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved 无法计算构建计划:插件org.apache.maven.plugins:maven-resources-plugin:2.5或其中一个依赖项无法解析

I had the same issue. 我遇到过同样的问题。 I changed the apache maven plugin version in pom.xml to the version used by the web-app in web.xml . 我将pom.xml中的apache maven插件版本更改为web.xml中 web-app使用的版本。 Then Maven > Update Project. 然后Maven>更新项目。

Note: The jdk/jre should be compatible to plugins you are using. 注意:jdk / jre应与您正在使用的插件兼容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM