Imported from land-of-apps/java-microservice-demo (
AGENTS.md). Install upstream withnpx skills add land-of-apps/java-microservice-demo. Copyright stays with the author.
Agent Development Notes for microservice-demo
This project is a Java Maven multi-module project consisting of two cooperating Spring Boot microservices.
Project Structure
- Root Directory:
microservice-demo/- Contains the parent
pom.xmland modules forservice-aandservice-b.
- Contains the parent
- service-a: Located at
microservice-demo/service-a/- Spring Boot application.
- Listens on port
8080. - Calls
service-bathttp://localhost:8081.
- service-b: Located at
microservice-demo/service-b/- Spring Boot application.
- Listens on port
8081. - Returns a simple "Hello from Service B" message.
Technologies
- Language: Java 17
- Build Tool: Maven
- Framework: Spring Boot 2.6.3
Key Files
microservice-demo/pom.xml: Parent POM, defines modules and dependency management.microservice-demo/service-a/pom.xml: Service A POM, includesspring-boot-starter-web.microservice-demo/service-b/pom.xml: Service B POM, includesspring-boot-starter-web.microservice-demo/service-a/src/main/java/com/example/servicea/ServiceAApplication.java: Main application class for Service A.microservice-demo/service-b/src/main/java/com/example/serviceb/ServiceBApplication.java: Main application class for Service B.microservice-demo/service-a/src/main/resources/application.properties: Service A configuration (port 8080).microservice-demo/service-b/src/main/resources/application.properties: Service B configuration (port 8081).
Development Workflow
- Build: Run
mvn clean installfrom themicroservice-demo/root directory. - Run Services:
- Start Service B:
java -jar microservice-demo/service-b/target/service-b-1.0-SNAPSHOT.jar - Start Service A:
java -jar microservice-demo/service-a/target/service-a-1.0-SNAPSHOT.jar - Both services need to be running concurrently for
service-ato successfully callservice-b.
- Start Service B:
- Test: Once both services are running, test
service-ausingcurl http://localhost:8080. This will trigger the call toservice-b.
Important Considerations
- When modifying code, ensure changes adhere to Spring Boot conventions.
- When adding new features or dependencies, update the respective
pom.xmlfiles. - Be mindful of port conflicts if running other services.
- The
RestTemplateinServiceAApplicationuseshttp://localhost:8081, soservice-bmust be accessible at that address. - Be sure to keep the documentation (including this file) up to date.