@EnableConfigurationProperties: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * Spring Boot Property Injection")
 
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:


* [[Spring_Boot_Property_Injection#.40EnableConfigurationProperties|Spring Boot Property Injection]]
* [[Spring_Boot_Property_Injection#.40EnableConfigurationProperties|Spring Boot Property Injection]]
=Overview=
Can be used to register classes that are not components, yet still want to take advantage of [[@ConfigurationProperties]] mechanism. If a regular component is annotated with [[@ConfigurationProperties]], it does not need help from @EnableConfigurationProperties.
=Example=
<syntaxhighlight lang='java'>
@EnableConfigurationProperties(MyConfig.class)
@ConfigurationProperties(prefix = "com.example.my.config")
public class MyConfig {
  ...
}
</syntaxhighlight>

Latest revision as of 22:01, 21 January 2019

Internal

Overview

Can be used to register classes that are not components, yet still want to take advantage of @ConfigurationProperties mechanism. If a regular component is annotated with @ConfigurationProperties, it does not need help from @EnableConfigurationProperties.

Example

@EnableConfigurationProperties(MyConfig.class)
@ConfigurationProperties(prefix = "com.example.my.config")
public class MyConfig {

   ...
}