Introduction

Collection of libraries (modules), each solving a specific problem, helps to build, run, and manage microservice systems.

Spring Boot  →  already built few services (different project)
Spring Cloud →  connect MANY services

Architecture

                 Client
                    ↓
          ┌──────────────────┐
          │  API Gateway     │
          └──────────────────┘
                    ↓
     ┌──────────────┼──────────────┐
     │              │              │
User Service   Order Service   Payment Service
     │              │              │
     └─────── registers with Eureka ┘
                    ↑
             Service Registry
                    ↑
             Config Server (Git)
             
# External traffic → Gateway only
# Internal traffic → Service ↔ Service (Eureka)

Spring Cloud infrastructure services

Each are different Spring Boot projects:

1. config-server    (Spring Cloud Config)
2. service-registry (Eureka Server)
3. api-gateway      (Spring Cloud Gateway)

Config Server

  1. Create another Spring Boot project, just for config files.

    Git Repo (configs)
     ├── user-service.yml
     ├── order-service.yml
     ├── payment-service.yml
     └── gateway.yml
    
  2. Dependency: spring-cloud-starter-config

  3. Main class enable config server

    @SpringBootApplication
    @EnableConfigServer
    public class ConfigServerApplication {
        public static void main(String[] args) {
            SpringApplication.run(ConfigServerApplication.class, args);
        }
    }