To prepare the project from future development, we will be creating a multi-maven project layout. Unfortunately, there’s no automated way to do that, so we will start by creating the root pom. It contains the group name, artifact name, etc, and most importantly packaging which is set to pom. This is how it looks like [refer to the folder].
It’s now time to set up our very first RESTful web service project.
Open Spring Tool Suite 4
Click File / New / Other and select Spring Starter Project
Set
Name=terawarehouse-catalog
Group=com.broodcamp
Artifact=terawarehouse-catalog
Description=Catalog Manager Service
Package=com.terawarehouse.catalog
Working set=terawarehouse
Click Next
In New Spring Project Dependencies windows select
H2 Database
REST Repositories HAL Browser
Spring Data JPA
Lombok
Spring Boot Actuator
Spring HATEOAS
Rest Repositories
Spring Boot DevTools
Spring Web Starter
Click Next and then Finish.
We will discuss their usage as we go along with the project.
Run the application by:
Right click on the project
Select Run As
Spring Boot App
By default, the application will run on port 8080. Let’s open it in the browser. This is where one of our dependencies kick in, the HAL Browser, which lists the API for Spring data.
Next, we will take a look at Actuator which is accessible at /actuator. It exposes a default set of APIs that provide the health information of the project. Let’s try /actuator/health.
More APIs can be exposed by changing the security configuration in the application.properties file. Set management.endpoints.web.exposure.include=*. After changing the file note that Spring STS will automatically update and redeploy the application. So we just need to refresh the page.
The list of exposed APIs should now be updated and must contain cache, login, metrics and so on [open metrics]. We can use these APIs to monitor our service.
- Database Initialization Using Script
Slack Discussion Repositories https://github.com/terawarehouse/terawarehouse-cataloghttps://github.com/terawarehouse/terawarehouse-reactThere are times when we want to use a SQL script to generate the schema and populate the database. Personally, I use...
- Database Initialization Using Code
Slack Discussion Repositories https://github.com/terawarehouse/terawarehouse-cataloghttps://github.com/terawarehouse/terawarehouse-reactThere are various ways in which we can initialize the database. Mostly for testing purposes I find setting hibernate.ddl-auto...
- Committing The Source Code On Github
Slack Discussion Repositories https://github.com/terawarehouse/terawarehouse-cataloghttps://github.com/terawarehouse/terawarehouse-reactTo commit our project in Github, make sure you already created a new Github repository and then: Get the repository...
- Spring Development Environment
Slack Discussion Repositories https://github.com/terawarehouse/terawarehouse-cataloghttps://github.com/terawarehouse/terawarehouse-reactBefore we can begin coding, we must first download and configure Spring Tools 4, which is the latest available Spring...
- Catalog And Sellout Management System Using Spring
A catalog and sales order management system is commonly used by companies to manage their catalog and capture their sales data into a centralized database so that a real-time accurate report can be generated instantly. This application can trigger notification...