κΆκΈν μ
β’
HikariConfig λ₯Ό λ΄κ° μ€μ ν λ΄μ©μΌλ‘ μ μ©νκΈ° μν΄ λΉμΌλ‘ λ±λ‘νκ³ μ λ©μλμ @Bean μΌλ‘ λ±λ‘νλ €κ³ νμλ€.
β’
@ConfigurationProperties λ‘ λ΄κ° yaml νμΌμ μ μ λ΄μ©μΌλ‘ νλ €κ³ νμλ€.
β’
κ·Έλ°λ° μ΄μνκ² λ΄κ° ν κ² λμ§ μμλ€.
β’
κ·Έλμ μ λμνλ μ½λλ₯Ό κ°μ Έμμ λλ²κ·Έλ₯Ό μ°μ΄λ³΄μλ€.
β’
λΉμ μμ±ν λμλ μ€μ λ΄μ©μ΄ μ μ©λμ§λ μμλ€.
κ³Όμ
Config
β’
new HikariConfig() λ‘ return νμλ€.
AbstractAutowireCapableBeanFactory
β’
L:414 applyBeanPostProcessorsBeforeInitialization λ©μλ
β¦
λ±λ‘λ beanPostProcessor λ€μ λ°λ³΅ λλ©΄μ post processing νλ€.
β¦
17κ°κ° λ±λ‘λμ΄μλ€.
ConfigurationPropertiesBindingPostProcessor
β’
λ€λ₯Έ beanPostProcessor λ€μ λ€λ₯Έ λ¬Έμ μμ΄ κΈ°μ‘΄μ HikariConfig(μ€μ μ΄ μ μ₯μ΄ μλ)κ° λ°νλλ€.
β’
κ·Έλ¬λ€κ° ApplicationContextAwareProcessor μμ postProcessing νλ BoundConfigurationProperties λ‘ λ°λμλ€.
β’
BoundConfigurationProperties λ μλ§ λ΄κ° μ€μ ν λ΄μ©μΈλ―
λ΄μΌ 곡λΆν κ±°
β’
μ²μ bean μ΄ HikariConfig μΌ λλ ConfigurationPropertiesBindingPostProcessor λ₯Ό κ±°μΉλ©΄ BoundConfigurationProperties κ° λλ€.
β’
BoundConfigurationProperties κ° λ€μ 17κ°λ₯Ό λ€μ λλ€.
β’
ConfigurationPropertiesBindingPostProcessor$postProcessBeforeInitialization μμ bind ν λ BoundConfigurationProperties λ‘ λ€μ λκΈ° μμνλ€.
JavaBeanBinder
β’
L:82 bind μμ ν¨
β’
νκ²(HikariConfig)μ field λ₯Ό λλ©΄μ λ°μΈλ© ν νλ‘νΌν°λ€ μ°Ύμμ λ°μΈλ©
λ¬Έμ ν΄κ²°
β’
μ§μ§ μ€μ κ°μ μ°Ύλ λΆλΆμ Binder$findProperty(L:441)
β’
source λ€μ λλ©΄μ(map λ±λ±μ΄ μλ€) μλ§λ μμ€λ‘ κ°μ ν λΉνλ€.
β’
μλλ©΄ ymlμ source λ‘ ν΄μ μ°Ύλλ€.
β’
λ¬Έμ κ° λμλλ©΄ λ©ν° λͺ¨λμμ ν΄λΉ yaml νμΌμ import νμ§ μμλ€.
β’
μ°Ύμμ λ€νμ΄λ€!