14. Spring Cloud Config / Actuator
- 📚 Spring/Spring Cloud
- 2023. 2. 13. 10:30
| Spring Cloud Config
- 분산 시스템에서 서버, 클라이언트 구성에 필요한 설정 정보 application.yml을 외부 시스템에서 관리
- 하나의 중앙화 된 저장소에서 구성요소 관리 가능
- 각 서비스를 다시 빌드하지 않고, 바로 적응 가능
- 애플리케이션 배포 파이프라인을 통해 DEV-UAT-PROD 환경에 맞는 구성 정보 사용
💻 Config Server를 추가하면 아래와 같이 Dependency가 추가된다
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
💻 ConfigServiceApplication에 @EnableConfigServer 추가
package com.kyhslam.configservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication
@EnableConfigServer
public class ConfigServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServiceApplication.class, args);
}
}
💻 application.yml
server:
port: 8888
spring:
application:
name: config-service
cloud:
config:
server:
git:
uri: file:C:\\\Dev\Spring_Cloud_Work\git-local-repo
| Spring Boot Actuator
- Application 상태, 모니터링
- Metric 수집을 위한 Http End Point 제공
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
WebSecurity.java > configure에 추가
http.authorizeRequests().antMatchers("/actuator/**").permitAll();
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
http.authorizeRequests().antMatchers("/actuator/**").permitAll();
http.authorizeRequests().antMatchers("/**")
.hasIpAddress("localhost")
.and()
.addFilter(getAuthentionFilter());
}
application.yml
management:
endpoints:
web:
exposure:
include: refresh, health, beans
'📚 Spring > Spring Cloud' 카테고리의 다른 글
16. Spring Cloud Bus (0) | 2023.05.10 |
---|---|
[Error] JWT 구현 시 javax/xml/bind/DatatypeConverter 에러 대처법 (0) | 2023.05.04 |
13. User-Service - AuthorizationHeaderFilter 추가 (0) | 2023.02.13 |
12. User-Service JWT 생성 (0) | 2023.02.12 |
11. User-Service에 인증권한 추가 (Authentication) (0) | 2023.02.05 |