Why can't my Eclipse/Maven/Spring project see the annotation @RequestMapping?

Robert Hume Source

I have a simple maven project in Eclipse for a web app.

I added the following dependencies to the pom.xml file ...


I created a simple web controller class ...

import org.springframework.stereotype.Controller;

public class WebController {

    public String method0(){
        return "method0";


... the project can find the @Controller annotation fine, but there's red errors on the @RequestMapping and @ResponseBody annotations.

I cleaned everything, rebuilt everything, no luck.

I checked the Java Build Path in the project, and the "Maven Dependencies" is added to the path, and it includes the following JARs ...

spring jcl-5.0.4.RELEASE.jar

Also, my understanding is the org.springframework.web.bind.annotation.RequestMapping annotation is supposed to be in the spring-webmvc-5.0.4.RELEASE.jar, but I unzipped the JAR file and I don't see it in there.

What am I doing wrong?



answered 7 months ago Robert Hume #1

I found a solution. I deleted the spring-web and spring-webmvc jars from my .m2 repository and did a maven clean and maven install, it re-downloaded the JAR files and now the JAR file has the correct files in it. Perhaps something went wrong the last time it download the dependencies, very weird. But working now so I'm good.

comments powered by Disqus