[PPN-211113] Implement ConfigurationProperties
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
dependencies {
|
||||
runtimeOnly 'mysql:mysql-connector-java'
|
||||
compileOnly 'org.projectlombok:lombok'
|
||||
|
||||
// https://projectreactor.io/docs/core/release/reference/#debug-activate
|
||||
implementation 'org.springframework.boot:spring-boot-starter-webflux'
|
||||
|
||||
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
|
||||
annotationProcessor 'org.projectlombok:lombok'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-webflux'
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.support.webclient;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* PpomppuNotifierWebClientConfiguration
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-11-18
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(value = "webclient.init", havingValue = "true")
|
||||
@ComponentScan(basePackageClasses = WebClientBaseScan.class)
|
||||
public class PpomppuNotifierWebClientConfiguration {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.support.webclient.properties;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* WebClientPropertiesUnit
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-11-18
|
||||
*
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Setter
|
||||
@Getter
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "webclient")
|
||||
public class WebClientProperties {
|
||||
|
||||
private List<WebClientPropertiesUnit> units = new ArrayList<>();
|
||||
|
||||
@Data
|
||||
public static class WebClientPropertiesUnit {
|
||||
private String unitName;
|
||||
private String baseUrl;
|
||||
// TODO headers
|
||||
}
|
||||
|
||||
public WebClientPropertiesUnit find(@NonNull String unitName) {
|
||||
return units.stream()
|
||||
.filter(x -> x.getUnitName().equals(unitName))
|
||||
.findFirst()
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException("Not found properties unit. unitName : " + unitName));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user