Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

spring - Maven Project in Eclipse `org.springframework cannot be resolved to a type` from target path

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.

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 Dependencies Showing:

enter image description here

Facets Enabled:

enter image description here

Project Explorer View:

enter image description here

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:

  • Delete project from the Eclipse.

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...