Running the service
Building upon Chapter 2, Building RESTful Web Services with Maven and Gradle, we can quickly get our service up and running by using Spring Boot. For this purpose, we need to create a main class, as follows:
package com.packtpub.springrest.inventory;
// imports omitted
@SpringBootApplication
public class WebApplication {
public static void main(String[] args) {
SpringApplication.run(new Object[]{WebApplication.class, "inventory.xml"}, args);
InventoryService inventoryService = context.getBean(InventoryService.class);
}
}
Running this class in your favorite IDE will start an embedded Tomcat instance and expose your resources. The service will be accessible at http://localhost:8080
. For example, accessing http://localhost:8080/rooms/1
will return the following:
{ "id": 1, "name": "Room 1", "roomCategoryId": 1, "description": "Nice, spacious double bed room with usual amenities" }