0Pricing
Spring Boot 4 Microservices & REST APIs · Aula

O servidor de configuração

Forneça a configuração a partir de um servidor central.

O servidor de configuração é uma aula grátis de Spring Boot 4 Microservices & REST APIs no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Spring Boot 4 Microservices & REST APIs, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Spring Boot 4 Microservices & REST APIs inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

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-repo

Running on a known port

Config Servers conventionally run on port 8888 so clients can find them with default settings.

server:
  port: 8888

How 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=prod

Native (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:./config

Securing 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

Perguntas Frequentes

A aula “O servidor de configuração” é grátis?

Sim — o texto completo de “O servidor de configuração” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Spring Boot 4 Microservices & REST APIs, atualize para CoddyKit PRO. O curso de Spring Boot 4 Microservices & REST APIs inclui 4 aulas no total.

O que vou aprender em “O servidor de configuração”?

Forneça a configuração a partir de um servidor central. Você pratica Spring Boot 4 Microservices & REST APIs com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Spring Boot 4 Microservices & REST APIs?

Nenhuma experiência prévia é necessária. Spring Boot 4 Microservices & REST APIs no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.

Quanto tempo leva a aula “O servidor de configuração”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Spring Boot 4 Microservices & REST APIs?

Sim. Cada aula de Spring Boot 4 Microservices & REST APIs inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. O servidor de configuração
  2. Configuração respaldada pelo Git
  3. Clientes de configuração
  4. Atualizando a configuração em tempo de execução
← Voltar para Spring Boot 4 Microservices & REST APIs