How to Use Apollo Config Center with Spring Boot: From Setup to Dynamic Updates

This guide walks through the fundamentals of Apollo Config Center, explains its core concepts, architecture, and dimensions, and demonstrates how to create a Spring Boot client, configure it for dynamic updates, test environment changes, and deploy the application on Kubernetes.

Top Architect
Top Architect
Top Architect
How to Use Apollo Config Center with Spring Boot: From Setup to Dynamic Updates

This article introduces Apollo, Ctrip's open‑source configuration management platform, and explains why traditional file‑based or database configurations no longer meet modern microservice needs. It outlines the four key dimensions—application, environment, cluster, and namespace—and describes how Apollo stores and pushes configuration changes in real time.

Basic Concepts and Architecture

Apollo consists of two main services: Config Service (provides read and push capabilities for clients) and Admin Service (handles configuration edits and releases). Both services are stateless, register with Eureka, and are often co‑located with a Meta Server that abstracts service discovery. Clients maintain a long‑poll HTTP connection to receive push notifications, with a fallback pull mechanism every five minutes.

Setting Up a Project

The tutorial shows how to create a Spring Boot project, add the apollo-client dependency, and configure application.yml with essential properties such as apollo.meta, apollo.cluster, apollo.bootstrap.enabled, and the namespaces to use. It also demonstrates adding JVM arguments ( -Dapollo.configService=… -Denv=DEV) to point the client to the correct Apollo instance.

Creating and Testing Configurations

Steps include logging into the Apollo portal, creating a project, adding a key‑value pair (e.g., test=123456), publishing it, and then accessing a simple @RestController endpoint ( /test) that returns the current value. The article verifies that changes made in the portal are reflected instantly in the running application, and also shows rollback behavior and client fallback to local cache when the server is unreachable.

Exploring Environments, Clusters, and Namespaces

Examples illustrate switching between DEV and PRO environments by adjusting the env JVM flag and apollo.meta URL, selecting different clusters (e.g., beijing vs shanghai) via the apollo.cluster setting, and using multiple private namespaces ( dev-1, dev-2) to isolate configuration sets.

Kubernetes Deployment

The guide details building a Docker image with JAVA_OPTS and APP_OPTS environment variables, creating a Kubernetes Service and Deployment manifest, and injecting Apollo parameters through the APP_OPTS variable. After applying the manifest, the application can be accessed via a NodePort, confirming that Apollo‑driven configuration works in a containerized environment.

Overall, the article provides a comprehensive, step‑by‑step walkthrough for developers who need a reliable, dynamic configuration solution in Java microservices.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

KubernetesConfiguration Managementspring-bootApollodynamic-config
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.