Skip to content

Latest commit

ย 

History

History
85 lines (61 loc) ยท 1.53 KB

Assistant-Properties.md

File metadata and controls

85 lines (61 loc) ยท 1.53 KB

Assistant Properties

์œ„ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ ์œ ์ €๊ฐ€ ์ถ”๊ฐ€ํ•œ properties ์†์„ฑ๋“ค๋„ ์ž๋™ ์™„์„ฑ์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.

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 ์†์„ฑ๊ฐ’๊ณผ ๋ฐ”์ธ๋”ฉ ๋  ๊ฐ์ฒด์ž…๋‹ˆ๋‹ค.

Plugin ์ถ”๊ฐ€

๋Œ€๋ถ€๋ถ„ ์ด๋ฏธ ์„ค์น˜๊ฐ€ ๋˜์–ด์žˆ์„ ๊ฒ๋‹ˆ๋‹ค.

์˜์กด์„ฑ ์ถ”๊ฐ€

maven

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-configuration-processor</artifactId>
    <optional>true</optional>
</dependency>

gradle

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"
}

Intellij ์„ค์ •

Settings > Build, Execution & Deployment > Compiler > Annotation Processors ์—์„œ Enable annotation processing๋ฅผ ์ฒดํฌ