Config Server
中央サーバーから設定を提供します
「Config Server」はCoddyKit上の無料Spring Boot 4 Microservices & REST APIsレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはSpring Boot 4 Microservices & REST APIs学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Spring Boot 4 Microservices & REST APIsコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
The configuration problem
In a microservices system, many services each need configuration. Duplicating application.yml everywhere is error-prone. Spring Cloud Config centralizes configuration in one server.
What the Config Server does
The Config Server is a small Spring Boot app that serves configuration to client services over HTTP, typically backed by a Git repository.
- One place to view and change config
- Versioned, auditable changes
Adding the server dependency
Create a new app and add spring-cloud-config-server.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>@EnableConfigServer
Annotate the main class with @EnableConfigServer to turn the app into a Config Server.
@SpringBootApplication
@EnableConfigServer
public class ConfigServerApp {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApp.class, args);
}
}Pointing at a backend
The server needs a backend to read config from. The most common is a Git repo, set with spring.cloud.config.server.git.uri.
# application.yml of the server
spring:
cloud:
config:
server:
git:
uri: https://github.com/acme/config-repoRunning on a known port
Config Servers conventionally run on port 8888 so clients can find them with default settings.
server:
port: 8888How config is addressed
The server resolves config by application name and profile. A client named orders with profile prod maps to files like orders-prod.yml in the repo.
The server HTTP API
You can query the server directly. The path is /{application}/{profile} and it returns the merged properties as JSON.
// GET http://localhost:8888/orders/prod
// returns merged config for app=orders, profile=prodNative (filesystem) backend
For local development you can use a filesystem backend instead of Git via the native profile - convenient but not versioned.
spring:
profiles:
active: native
cloud:
config:
server:
native:
search-locations: file:./configSecuring the server
Config can contain secrets, so protect the server with HTTP Basic auth (Spring Security) and run it behind your private network. Clients then send credentials.
Encryption support
The server can store encrypted values (prefixed {cipher}) and decrypt them on the fly, so secrets are never stored in plaintext in the repo - provided a key is configured.
Quick Check
Check your Config Server fundamentals.
Recap
You stood up a Config Server:
- It centralizes config and serves it over HTTP
@EnableConfigServer+ a Git (or native) backend- Runs on port 8888 by convention
- Resolves config by application name and profile
よくある質問
「Config Server」レッスンは無料ですか?
はい。「Config Server」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Spring Boot 4 Microservices & REST APIsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Spring Boot 4 Microservices & REST APIsコースには全4レッスンが含まれています。
「Config Server」で何を学びますか?
中央サーバーから設定を提供します ブラウザで直接実行するハンズオンコードでSpring Boot 4 Microservices & REST APIsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Spring Boot 4 Microservices & REST APIsを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのSpring Boot 4 Microservices & REST APIsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。
「Config Server」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このSpring Boot 4 Microservices & REST APIsレッスンでコードを書いて実行できますか?
はい。すべてのSpring Boot 4 Microservices & REST APIsレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- Config Server
- Git管理の設定
- Config Client
- 実行時に設定を更新する