springeclipserestmaven

Simple REST service with Spring framework not using Spring Boot


I want to start with the most simple Maven Project with a simple REST resource not using Spring Boot and generate a .war artifact that is deployed in a servlet container. I am using Eclipse IDE. So I would like to know what is the basic things in place needed to create such a Project.

I think I need at least this dependences:

I also need the stuff with a class annotated with the @RestController annotation, with some method annotated with the @Requestmapping and so.

But whats the minimum content I should have in the WebContent directory and its subfolders META-INF, WEB-INF ... in order to the servlet container to know how to use the .war component? I dont want any HTML nor JSP pages.


Solution

  • In your WEB-INF folder, you will need a web.xml file. This is where you will configure your dispatcher servlet. This is the part of your application that receives requests and delegates them to the appropriate part of your application.

    You will also need some sort of REST configuration file. You can define beans for Spring and component scan config.

    A good explanation of this can be found here, https://www.programming-free.com/2014/01/spring-mvc-40-restful-web-services.html