Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What dependency is missing for org.springframework.web.bind.annotation.RequestMapping?

Tags:

rest

spring

maven

What dependency am I missing? I am currently using:

<dependency>     <groupId>org.springframework</groupId>     <artifactId>spring-web</artifactId>     <version>3.0.5.RELEASE</version> </dependency> <dependency>     <groupId>org.springframework</groupId>     <artifactId>spring-webmvc</artifactId>     <version>3.0.5.RELEASE</version> </dependency> 

The error Im getting is: The import org.springframework.web.bind cannot be resolved

like image 829
Rolando Avatar asked Dec 07 '11 21:12

Rolando


People also ask

What is the @RequestMapping annotation used for?

annotation. RequestMapping annotation is used to map web requests onto specific handler classes and/or handler methods. @RequestMapping can be applied to the controller class as well as methods.

What is @RequestMapping annotation in spring boot?

One of the most important annotations in spring is the @RequestMapping Annotation which is used to map HTTP requests to handler methods of MVC and REST controllers. In Spring MVC applications, the DispatcherServlet (Front Controller) is responsible for routing incoming HTTP requests to handler methods of controllers.

What is request mapping spring?

@RequestMapping is one of the most common annotation used in Spring Web applications. This annotation maps HTTP requests to handler methods of MVC and REST controllers.


1 Answers

I had the same problem. After spending hours, I came across the solution that I already added dependency for "spring-webmvc" but missed for "spring-web". So just add the below dependency to resolve this issue. If you already have, just update both to the latest version. It will work for sure.

<dependency>     <groupId>org.springframework</groupId>     <artifactId>spring-web</artifactId>     <version>4.1.6.RELEASE</version> </dependency> 

You could update the version to "5.1.2" or latest. I used V4.1.6 therefore the build was failing, because this is an old version (one might face compatibility issues).

like image 108
Ram Avatar answered Sep 20 '22 21:09

Ram