Creating a RESTful web service
In Spring Boot, all HTTP requests are handled by controller classes. To be able to create a RESTful web service, first, we have to create a controller class. We will create our own Java package for the controller:
Activate the root package in the Eclipse Project Explorer and right-click. Select New | Package from the menu. We will name our new package
com.packt.cardatabase.web
:Next, we will create a new
controller
class in a new web package. Activate thecom.packt.cardatabase.web
package in the Eclipse Project Explorer. Right-click and select New | Class from the menu; we will name our classCarController
:Now, your project structure should look like the following screenshot:
IMPORTANT NOTE
If you create classes in the wrong package accidentally, you can drag and drop the files between packages in the Eclipse Project Explorer. Sometimes, the Eclipse Project Explorer...