์ ๊ทธ๋ฆผ์ฒ๋ผ ์ ์ ๊ฐ ์ถ๊ฐํ properties ์์ฑ๋ค๋ ์๋ ์์ฑ์ ์ง์ํฉ๋๋ค.
Properties ์์ฑ์ด ์ฝ๋์ ๋ฐ์ธ๋ฉ ๋๋์ง ํ์ธ ํ ์ ์์ด ์์ฃผ ์ ์ฉํฉ๋๋ค.
sample:
email: "yun@test.com"
name : "yun"
age: 27
auth: true
@Configuration
@ConfigurationProperties(prefix = "sample")
public class SampleProperties {
private String email;
private String name;
private int age;
private boolean auth;
// getter, setter
}
Properties ์์ฑ๊ฐ๊ณผ ๋ฐ์ธ๋ฉ ๋ ๊ฐ์ฒด์ ๋๋ค.
๋๋ถ๋ถ ์ด๋ฏธ ์ค์น๊ฐ ๋์ด์์ ๊ฒ๋๋ค.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
}
}
apply plugin: 'nebula.optional-base'
...
dependencies {
optional "org.springframework.boot:spring-boot-configuration-processor"
}
Settings > Build, Execution & Deployment > Compiler > Annotation Processors
์์ Enable annotation processing
๋ฅผ ์ฒดํฌ