Skip to content

Add Spring Cloud Config Server for centralized configuration management#10

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1760129258-config-server
Open

Add Spring Cloud Config Server for centralized configuration management#10
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1760129258-config-server

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 10, 2025

Copy link
Copy Markdown

Add Spring Cloud Config Server for Centralized Configuration Management

Summary

This PR introduces a new Config Server microservice that centralizes configuration management for all services in the BankingMicroservices application. All 7 existing microservices have been updated to connect to the Config Server via bootstrap.yml files.

Key Changes:

  • Created new Config-Server microservice with Spring Cloud Config (native profile, port 8888)
  • Migrated all service configurations to centralized YAML files in Config-Server/src/main/resources/config/
  • Added spring-cloud-starter-config dependency and bootstrap.yml to all 7 services
  • Security improvement: Keycloak client secrets now use environment variables without defaults
  • Bug fix: Fixed duplicate route ID fund-transfer-service in API Gateway (renamed second one to fund-transfer-service-direct)

Modified Services:

  • Service Registry, API Gateway, User Service, Account Service, Fund Transfer Service, Transaction Service, Sequence Generator

Review & Testing Checklist for Human

⚠️ This PR requires careful end-to-end testing as I could only verify compilation, not runtime integration.

  • [CRITICAL] Test Config Server integration: Start Service Registry → Config Server → another service (e.g., Sequence-Generator). Verify the service successfully retrieves config from Config Server (check startup logs for "Located property source" message)
  • [CRITICAL - BREAKING CHANGE] Set required Keycloak environment variables before starting services that need them:
    • KEYCLOAK_CLIENT_SECRET (for API Gateway)
    • KEYCLOAK_API_CLIENT_SECRET (for User Service)
    • These no longer have defaults for security reasons. Services will fail to start without them.
  • Test the duplicate route fix: Verify both /api/fund-transfers/** and /fund-transfers/** paths work correctly through API Gateway
  • Verify startup order works: Service Registry (8761) → Config Server (8888) → Other services
  • Test database environment variable substitution still works (MYSQL_HOST, MYSQL_PORT, etc.)

Test Plan Recommendation

# 1. Start Service Registry
cd Service-Registry && mvn spring-boot:run

# 2. Start Config Server (wait for Service Registry to be ready)
cd Config-Server && mvn spring-boot:run

# 3. Start a test service like Sequence-Generator
cd Sequence-Generator && mvn spring-boot:run
# Check logs for: "Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}]"

# 4. For API Gateway and User Service, set env vars first:
export KEYCLOAK_CLIENT_SECRET=<your-secret>
export KEYCLOAK_API_CLIENT_SECRET=<your-secret>
cd API-Gateway && mvn spring-boot:run

Notes

  • All original application.yml files remain as fallback configuration
  • Config Server uses native (filesystem) profile - configs are in classpath, not Git
  • The duplicate route ID bug existed in the original code and has been fixed in this PR
  • Verified all services compile successfully with new dependencies

Link to Devin run: https://app.devin.ai/sessions/3105908d0528476ba646be704e6815e4
Requested by: Sam Fertig (@samfert-codeium)

- Created Config-Server microservice with Spring Cloud Config Server dependency
- Implemented ConfigServerApplication with @EnableConfigServer annotation
- Configured native profile for filesystem-based configuration storage
- Created centralized configuration files for all 7 microservices:
  * service-registry.yml
  * api-gateway.yml
  * user-service.yml
  * account-service.yml
  * fund-transfer-service.yml
  * transaction-service.yml
  * sequence-generator.yml
- Standardized environment variable substitution across all configs:
  * Database: MYSQL_HOST, MYSQL_PORT, MYSQL_DB_NAME, MYSQL_USER, MYSQL_PASSWORD
  * Keycloak: KEYCLOAK_CLIENT_SECRET, KEYCLOAK_API_CLIENT_SECRET (required env vars)
- Added spring-cloud-starter-config dependency to all 7 microservices
- Created bootstrap.yml files for all services to connect to Config Server
- Added Dockerfile for Config-Server following existing service patterns
- Added comprehensive README.md for Config-Server
- Preserved all existing application.yml files as fallback configuration

Config Server runs on port 8888 (standard Spring Cloud Config port)
Recommended startup order: Service Registry → Config Server → Other services

All services verified to compile successfully with new configuration approach.

Link to Devin run: https://app.devin.ai/sessions/3105908d0528476ba646be704e6815e4
Requested by: Sam Fertig (@samfert-codeium)

Co-Authored-By: Sam Fertig <sam.fertig@codeium.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@samfert samfert requested a review from Copilot October 10, 2025 20:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a centralized configuration management system for the banking microservices application using Spring Cloud Config Server. The implementation enables all 7 microservices to retrieve their configurations from a central location while maintaining backward compatibility with local configuration files.

  • Implements a new Config Server microservice with native file-based configuration storage
  • Updates all client services to connect to the Config Server via Spring Cloud Config Client
  • Migrates configuration files to a centralized location with environment variable support for database credentials and Keycloak secrets

Reviewed Changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Config-Server/pom.xml New Maven configuration for Config Server with Spring Cloud Config Server dependency
Config-Server/src/main/java/org/training/config/server/ConfigServerApplication.java Main application class with @EnableConfigServer annotation
Config-Server/src/main/resources/application.yml Config Server settings using native profile with classpath config location
Config-Server/src/main/resources/config/*.yml Centralized configuration files for all 7 microservices
*/src/main/resources/bootstrap.yml Bootstrap configurations for each service to connect to Config Server
*/pom.xml Added spring-cloud-starter-config dependency to all client services
Config-Server/README.md Comprehensive documentation for the Config Server
Config-Server/Dockerfile Docker configuration for containerized deployment

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

uri: lb://transaction-service
predicates:
- Path=/transactions/**
- id: fund-transfer-service

Copilot AI Oct 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate route definition for fund-transfer-service. There are two routes with the same ID (lines 26-29 and 42-45) but different path patterns. This creates a duplicate route ID which could cause routing conflicts or unexpected behavior.

Suggested change
- id: fund-transfer-service
- id: fund-transfer-service-no-api

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +20

show-sql: true

Copilot AI Oct 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Inconsistent YAML formatting with unnecessary blank lines within the jpa configuration block. The indentation structure should be consistent without extra blank lines between related properties.

Suggested change
show-sql: true
show-sql: true

Copilot uses AI. Check for mistakes.
Address PR review comments:
- Rename duplicate route ID 'fund-transfer-service' to 'fund-transfer-service-direct' for the /fund-transfers/** path in api-gateway.yml (line 42)
- Remove unnecessary blank lines in fund-transfer-service.yml JPA configuration block (lines 18, 20)

This fixes a pre-existing bug where two routes had the same ID, which could cause routing conflicts in Spring Cloud Gateway.

Co-Authored-By: Sam Fertig <sam.fertig@codeium.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant