Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experiment #3 - configuration properties in variety of methods
여러 방법으로 properties 사용 방법을 실험 행한 실험은: * actuator endpoint 전부 개방 * `@ConstructorBinding` -> 2.2 기능 * `@DefaultValue` -> 2.2 기능 * `@DurationUnit`을 `@ConstructorBinding` 생성자에 사용 * `@name` * `.properties` 에 yaml 처럼 문서 구분하기 * 프로파일 설정 * 부트 프로퍼티 변화: `spring.profiles` -> `spring.config.activate.on-profile` * `spring.config.import` * 여러개 `spring.config.import` * config tree * 확장자 없는 properties 파일
- Loading branch information
Showing
6 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/com/fastcampus/springbootpractice/properties/CustomProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.fastcampus.springbootpractice.properties; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.context.properties.ConstructorBinding; | ||
import org.springframework.boot.context.properties.bind.DefaultValue; | ||
import org.springframework.boot.context.properties.bind.Name; | ||
import org.springframework.boot.convert.DurationUnit; | ||
|
||
import java.time.Duration; | ||
import java.time.temporal.ChronoUnit; | ||
|
||
@ConstructorBinding | ||
@ConfigurationProperties("iam") | ||
public class CustomProperties { | ||
|
||
/** | ||
* 와아 이건 configuration processor 테스트 | ||
*/ | ||
private final Duration duration; | ||
|
||
public CustomProperties(@DefaultValue("1") @DurationUnit(ChronoUnit.MILLIS) @Name("duration") Duration duration) { | ||
this.duration = duration; | ||
} | ||
|
||
public Duration getDuration() { | ||
return duration; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
logging.logback.rollingpolicy.file-name-pattern=rolling.txt | ||
management.endpoints.web.exposure.include=* | ||
spring.config.import=classpath:my[.properties],configtree:/Users/Uno/Documents/github/fastcampus-spring-boot-practice/src/main/resources/tree/ | ||
spring.profiles.active=test | ||
|
||
#--- | ||
|
||
spring.config.activate.on-profile=fastcampus | test | ||
iam.duration=5s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
iam.duration=10s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
12s |