Employee Address Microservices is a Spring Boot-based project that demonstrates communication between two independent microservices using RestTemplate.
The project consists of:
- Employee Service
- Address Service
The Employee Service retrieves employee details from its database and fetches the corresponding address from the Address Service using REST API communication.
Client
|
|
GET /api/v1/emp/{id}
|
Employee Service
Port : 9991
|
RestTemplate HTTP Call
|
V
Address Service
Port : 9992
|
MySQL
- Java 21
- Spring Boot
- Spring Data JPA
- Hibernate
- RestTemplate
- ModelMapper
- MySQL
- Maven
- Lombok
Port
9991
Responsibilities
- Fetch employee details
- Communicate with Address Service
- Return combined Employee + Address response
Port
9992
Responsibilities
- Fetch address information
- Return Address DTO
MySQL
Employee Table
emp71
Address Table
address70
GET /api/v1/getAll
GET /api/v1/emp/{id}
Example
GET http://localhost:9991/api/v1/emp/1
Response
{
"id":1,
"name":"John",
"email":"john@gmail.com",
"age":24,
"addressResponse":{
"id":1,
"city":"Hyderabad",
"state":"Telangana"
}
}GET /api/v1/add/{id}
Example
GET http://localhost:9992/api/v1/add/1
Response
{
"id":1,
"city":"Hyderabad",
"state":"Telangana"
}- Spring Boot REST APIs
- Microservices Architecture
- Service-to-Service Communication
- RestTemplate Integration
- ModelMapper for DTO Mapping
- Spring Data JPA
- Native SQL Query
- MySQL Database
- Maven Build
- Clean Layered Architecture
Employee-Address-Microservices
│
├── employeeservice
│ ├── Controller
│ ├── Service
│ ├── Repository
│ ├── Entity
│ ├── Response DTO
│ └── Configuration
│
├── addressservice
│ ├── Controller
│ ├── Service
│ ├── Repository
│ ├── Entity
│ ├── Response DTO
│ └── Configuration
│
└── README.md
git clone https://github.com/venky4378/Employee-Address-Microservices.gitUpdate the following in application.properties
spring.datasource.url
spring.datasource.username
spring.datasource.password
localhost:9992
localhost:9991
Use
- Browser
- Postman
- Spring Cloud Eureka Server
- API Gateway
- Config Server
- OpenFeign
- Spring Security + JWT
- Docker
- Swagger/OpenAPI
- Circuit Breaker (Resilience4j)
Swamy Ch
GitHub