This project demonstrates the capabilities of microservices architecture using a multi-module Gradle setup. The project is structured into multiple modules to exhibit different aspects and functionalities of a microservices ecosystem. The initial setup includes payment
and common
modules, among others, to showcase the application's modular structure and inter-service communication.
Utilizing Gradle's allprojects
and subprojects
configurations, this project is structured to have a common build and dependency management across all modules while allowing specific configurations for individual modules.
The allprojects
block in the root build.gradle
file defines common configurations, repositories, and dependencies that are shared across all modules.
allprojects {
repositories {
mavenCentral()
}
// ... other common configurations
}
You can use gradle instead of gradlew if you have it installed in your system.
To build the project, navigate to the project root directory and run:
./gradlew build
To run a specific module, navigate to the module directory and run:
./gradlew :moduleName:bootRun
Replace moduleName with the name of the module you wish to run.
To debug it use the following command:
gradle bootRun --debug-jvm
To start the Eureka server, navigate to the eureka-server
directory and run:
./gradlew clean build bootRun
or if you have a gradle installed in your system, you can run the following command:
gradle clean build bootRun
Now you can access to http://localhost:8761/ Eureka service.
To enable service discovery, we need to add the following configuration to the application.properties of the service we want to register with the Eureka server.
# eureka server client configuration
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.service-url.default-zone=http://localhost:8761/eureka/
spring.config.import=optional:configserver:http://localhost:8761
# Actuator Configuration to expose all endpoints
management.endpoints.web.exposure.include=*