@ConfigurationProperties

Reference: Spring Docs - @ConfigurationProperties

  • *.properties , *.yml ํŒŒ์ผ์— ์žˆ๋Š” property๋ฅผ ์ž๋ฐ” ํด๋ž˜์Šค์— ๊ฐ’์„ ๊ฐ€์ ธ์™€์„œ binding ํ•ด์ฃผ๋Š” annotation

  • ํ•ด๋‹น annotation์„ ์‚ฌ์šฉํ•˜๋ฉด ์—ฌ๋Ÿฌ ํ‘œ๊ธฐ๋ฒ•์— ๋Œ€ํ•ด ์ž๋™์œผ๋กœ binding ํ•ด์ค€๋‹ค

    • ex)

      acme.my-project.person.first-namepropertiesย ์™€ย .yml์—ย ๊ถŒ์žฅ๋˜๋Š” ํ‘œ๊ธฐ ๋ฐฉ๋ฒ•

      acme.myProject.person.firstName

      ํ‘œ์ค€ ์นด๋ฉœ ์ผ€์ด์Šค ๋ฌธ๋ฒ•.

      acme.my_project.person.first_name

      .properties์™€ .yml ์—์„œ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•œ ๋ฐฉ๋ฒ• ( - ํ‘œ๊ธฐ๋ฒ•์ด ๋” ํ‘œ์ค€ )

      ACME_MYPROJECT_PERSON_FIRSTNAME

      ์‹œ์Šคํ…œ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ๊ถŒ์žฅ

  • ํ•ด๋‹น property ํŒŒ์ผ์„ Bean์œผ๋กœ ๋“ฑ๋กํ•ด์ค˜์•ผ ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•œ๋‹ค

Last updated