Java Spring Boot Microservices Example - Step by Step Guide
1. Create a New Spring Boot Project in Spring Initializer in VSCode.
Spring Initializer: Create MAVEN Project->2.7.17->JAVA->Group ID->ArtfactID->->WAR->11-
>Select required dependencies(like, Spring WEB: Web) ->Automatically JAVA PROJECT Created.
2. Create a 3 new PACKAGES for ENTITY, Service, Controller and then Create JAVA Class inside
the each Package like Entity_Class, Service_Class, Controller_Class.
3. Create Your Entity/Model Class
Inside the Entity package we created our Entity Class then declare Structure, getter and
setter methods, Constructor methods.
put the below code and this is our model class.
4. Create Your Service Class
Put the below code. This is our service class where we write our business
logic.
5. Create a Controller
put the below code. Here we are going to create an endpoint.
6. Run Your Microservice:
Our code is running Successfully.
7. Default server PORT : 8080
Our local host already embedded with port number 8080.
If we want to change the port number then GOTO Application.Properties -> and TYPE server.port
= ‘Your port Number’ (like server.port = 8099).
8. Now, Goto web browser type your local host with endpoint
e.g : http://localhost:8088/customer
Finally, our output displayed successfully.