Eclipse`org.springframework中的Maven项目无法从目标路径解析为类型` [英] Maven Project in Eclipse `org.springframework cannot be resolved to a type` from target path

查看:299
本文介绍了Eclipse`org.springframework中的Maven项目无法从目标路径解析为类型`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经进入了一个Maven项目,当我从命令行运行mvn clean install时,它可以正常运行.在我精简系统之前的一周中,我在Eclipse中显示了该项目而没有错误.这使我认为我的配置有误,希望有人可以给我进行健全性检查.

I've rolled onto a maven project that when I run mvn clean install from command line builds and runs fine. I had this project displaying in Eclipse without errors earlier in the week before I hosed my system. This makes me think I have a configuration wrong and hoping someone can give me a sanity check.

在Eclipse内,我在<project_path>/target/<project>-<version>/WEB-INF/...这样的路径中的文件中看到与org.springframework cannot be resolved to a type相关的错误,引起我注意的是target的路径,该路径是派生文件夹.

Inside of Eclipse, I'm seeing reported errors related to org.springframework cannot be resolved to a type in files in paths like <project_path>/target/<project>-<version>/WEB-INF/... What is catching my eye is that path of target which is a derived folder.

Maven依赖项显示:

Maven Dependencies Showing:

已启用Facets:

项目资源管理器视图:

从上面的屏幕截图中,您可以看到相关的jar文件已从maven依赖项中正确提取.关于配置错误以及为什么我从目标路径中看到错误的任何想法?

From the above screenshots, you can see that the related jar files are pulled properly from the maven dependencies. Any ideas on what I have misconfigured and why I'm seeing the errors from the target path?

推荐答案

buildWebContent文件夹表明您没有正确地将Maven项目导入Eclipse,因此会出错.

The build and WebContent folders indicate that you haven't properly imported Maven project into the Eclipse, hence errors.

解决此问题的方法之一:

One of the way to fix this:

  • 从Eclipse删除项目.

  • Delete project from the Eclipse.

转到项目文件夹,然后删除所有不需要的文件夹. (请保留src).

Go to project folder and delete all not needed folders. (Leave src).

转到Eclipse,单击File-> Import...,选择Existing Maven Projects,选择项目文件夹Finish.

Go to Eclipse click File -> Import..., select Existing Maven Projects, select your project folder, Finish.

这篇关于Eclipse`org.springframework中的Maven项目无法从目标路径解析为类型`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆