Add ApiProperties

This commit is contained in:
woozu.shin 2021-10-18 14:16:09 +09:00
parent ebb0c75021
commit d330bc8df9
6 changed files with 87 additions and 0 deletions

View File

@ -17,8 +17,15 @@ ext {
}
dependencies {
implementation 'org.projectlombok:lombok'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
dependencyManagement {

View File

@ -0,0 +1,16 @@
package com.kakaoent.cpdd.config.client1.configuration.properties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Setter
@Getter
@Component
@ConfigurationProperties(prefix = "apis")
public class ApiProperties {
private String gateway; // client config
private String point; // server config
}

View File

@ -0,0 +1,29 @@
package com.kakaoent.cpdd.config.client1.controller;
import com.kakaoent.cpdd.config.client1.configuration.properties.ApiProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
@RequestMapping("/api/v1")
@RestController
public class PropertyAPIController {
private final ApiProperties apiProperties;
public PropertyAPIController(ApiProperties apiProperties) {
this.apiProperties = apiProperties;
}
@GetMapping("/apis/gateway")
public Mono<String> getGatewayUrl() {
return Mono.just(apiProperties.getGateway());
}
@GetMapping("/apis/point")
public Mono<String> getPointAPIUrl() {
return Mono.just(apiProperties.getPoint());
}
}

View File

@ -0,0 +1,7 @@
spring:
config:
activate:
on-profile: dev
apis:
gateway: http://gw.application-dev.com

View File

@ -0,0 +1,6 @@
spring:
config:
activate:
on-profile: prod
apis:
gateway: http://gw.application.com

View File

@ -1 +1,23 @@
server:
port: 11081
spring:
application:
name: app1
profiles:
active: dev
group:
dev: dev,datasource-dev,redis-dev
prod: prod,datasource-prod,redis-prod
config:
import: "optional:configserver:http://localhost:11080"
logging.level:
org: TRACE
management:
endpoints:
web:
exposure:
include: refresh