将 Maven 项目导入 Eclipse 并修复错误
我导入了一个项目到 eclipse 我在每个类名中都有很多错误,甚至像 String 这样的类......
我所做的类中的错误是 隐式超级构造函数 Object() 对于默认构造函数未定义。必须定义显式构造函数
并在方法
即使对于 IOException 我也收到 IOException 无法解析为类型
那么我应该做什么? 我尝试再次构建、清理,但没有使用
更新:我也得到了描述
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-resources-plugin:2.4.3:resources (execution: default-resources, phase: process-resources) pom.xml /test line 6 Maven Project Build Lifecycle Mapping Problem
I made imported a project to eclipse
and I have a lot of errors in every class name even classes like String ...
the error in the classes I made is Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor
and inside the methods <Class> cannot be resolved to a type
even to IOException I am getting IOException cannot be resolved to a type
so what should I do ?
I tried to build , clean again with no use
UPDATE : also I am getting Description
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-resources-plugin:2.4.3:resources (execution: default-resources, phase: process-resources) pom.xml /test line 6 Maven Project Build Lifecycle Mapping Problem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您导入的项目是 Maven 项目。您应该做的是打开位于项目根目录下的 pom.xml 文件,并在该文件的插件管理部分添加以下插件:
然后右键单击该项目,转到 Maven 并更新项目配置。
这应该可以解决它。
The project that you imported is a Maven project. What you should do is open the pom.xml file located in the root of the project and add the following plugin in the plugin management part of the file:
Then right click the project, go to Maven and Update project configuration.
This should fix it.
我认为你的问题不在 Maven 项目中,也不在导入过程中,而是在你的 Eclipse 配置中。看来你的 Eclipse“没有看到”正确的 JDK。
因此,首先尝试创建简单的“hello world”项目,看看它是否有效。当此工作正常时,再次导入您的 Maven 项目,即运行命令
mvn eclipse:eclipse
,然后使用 eclipse 打开该项目。如果这是您的第一个 Eclipse 项目,您必须创建 M2_REPO 变量来引用您的 Maven 存储库 (USER_HOME/.m2/repository
)。如果您仍然遇到问题,请尝试刷新并清理项目。
如果问题仍然发生,请比较您在“好”和“坏”项目中使用哪个 JDK。我相信你会看到那里的不同。所以,解决它。
I think that your problem is not in maven project and not in import procedure but in your eclipse configuration. It seems that your eclipse "does not see" correct JDK.
So, first try to create the simple "hello world" project and see if it works. When this works import your maven project again, i.e. run command
mvn eclipse:eclipse
and then open the project using eclipse. If this is your first eclipse project you have to create M2_REPO variable that will refer to your maven repository (USER_HOME/.m2/repository
)If you still have problems try to refresh and clean the project.
If the problem still happens compare which JDK are you using in "good" and "bad" project. I believe that you will see difference there. So, fix it.
您能够成功构建该项目吗?
如果是这样,请不要导入它..再次运行@项目根级别;
这将创建一个 Eclipse 项目。然后“导入为现有项目”。所有类路径问题都将得到解决。但是您需要将 .m2 home 设置为构建路径中的变量。
Were you able to build the project successfully..
If so, don't import it..again run @ project root level;
This will create a eclipse project.Then 'import as existing project.' All classpath problem will get solved..But you need to set your .m2 home as a variable in your build path..
转到
项目
->属性
->Java 构建路径
->库
。是否添加了JRE系统库?它指向正确的位置吗?还可以尝试在项目的根文件夹上运行
mvn eclipse:eclipse
(您需要先下载 maven 并将其添加到类路径中)。Go to
Project
->Properties
->Java build path
->Libraries
. Is the JRE System Library added? Does it point to the correct location?Also try running
mvn eclipse:eclipse
on the root folder of the project (You will need to download maven and add it to the classpath first).