Add spring-boot-microservices-project: config server, Eureka, gateway and three services on Boot 4.1.1 + Spring Cloud 2025.1.3

Product, order and inventory services behind Spring Cloud Gateway (WebMVC), configuration from a Config Server,
discovery with Eureka, a Resilience4j circuit breaker on order -> inventory and Brave tracing. Run as six plain jars;
output/ holds real transcripts (config, registry, requests, trace propagation, circuit breaker, startup race and the
load-balanced RestClient.Builder trap). Dockerfile and docker-compose.yml are included but were not run.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HhW8LD8r3EigoBaCGrQZx5
This commit is contained in:
Claude
2026-10-21 17:08:42 +00:00
commit def73fa1c4
49 changed files with 1419 additions and 0 deletions
@@ -0,0 +1,12 @@
package com.ankurm.shop.gateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/** The single public entry point. The routes are in config-server/src/main/resources/config/gateway.yml. */
@SpringBootApplication
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
}
}
@@ -0,0 +1,32 @@
package com.ankurm.shop.gateway;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
/**
* Logs one line per request. It runs inside the tracing filter, so the line carries the trace id the gateway
* created (or accepted from the caller) and passes on to every service behind it.
*/
@Component
class RequestLogFilter extends OncePerRequestFilter {
private static final Logger log = LoggerFactory.getLogger(RequestLogFilter.class);
@Override
protected boolean shouldNotFilter(HttpServletRequest request) {
return !request.getRequestURI().startsWith("/api/");
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws ServletException, IOException {
log.info("gateway received {} {}", request.getMethod(), request.getRequestURI());
chain.doFilter(request, response);
}
}
@@ -0,0 +1,16 @@
spring:
application:
name: gateway
config:
# Fail fast if the config server is not up: a service with the wrong config is worse than no service.
import: "configserver:${CONFIG_URL:http://localhost:8888}"
server:
port: 8080
eureka:
client:
service-url:
defaultZone: ${EUREKA_URL:http://localhost:8761/eureka}
instance:
hostname: ${EUREKA_HOSTNAME:localhost}
# Register the service name + port as the instance id so two copies of one service do not collide.
instance-id: ${spring.application.name}:${server.port}