“The import org.springframework cannot be resolved.”

You need to follow a few steps to debug properly.

1) mvn clean dependency:tree Take a look at the output to see exactly what you get and verify your dependencies are all there.

2) mvn clean compile. Does this fail? If not does that mean you only get the error in Eclipse?

You mentioned in a comment “And I run both commands above but I am getting this error”. Did mvn clean compile work? Or did you get an error for that as well? If it worked then it’s just an IDE problem and I’d look at the m2eclipse plugin. Better still, use IntelliJ as the free version has better maven support than Eclipse 😉

Some style things …

People often add too many dependencies in their pom file when they don’t need to. If you take a look at a couple of links in mavenrepository.com you can see that spring-oxm and spring-jdbc both depend on spring-core so you don’t need to add that explicitly (for example). mvn clean dependency:tree will show you what is coming in after all of that, but this is more tidying.

Leave a Comment