You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
because I am working on utilizing it for the creation of custom properties on my Spring Boot application. Unfortunately, while the information you gave was pretty complete on how to use @ConfiguratioProperties to create configuration properties, there is one pretty major piece of information that is missing:
How do you access the properties once you have defined them and made Spring boot "aware" of them???
Using your properties as an example: you made the MailModuleProperties class to add the twp properties "enabled" and "defaultSubject", and you created two versions of the MailModuleConfiguration class to make a MailModuleProperties instance available to the Spring Boot application. Well and good, but how do you actually access and use the two properties once you make them together?
Suppose I want to create a Controller class with a @GetMapping annotated method that wraps the value of the "defaultSubject" property in some HTML and returns it to a client application or browser? How do I access the MailModuleProperties instance in order to get the property???
I did try to use the @value annotation to set a string to the value of defaultSubject for use in a Controller method, but the string was null when I attempted to use it.
Without that critical piece of information, your information about using @ConfigurationProperties is pretty unusable.
Can you please include an example of how one actually accesses and uses the properties you made in a Controller or Service class?
The text was updated successfully, but these errors were encountered:
I have looked with great interest at your @ConfigurationProperties article and code:
https://reflectoring.io/spring-boot-configuration-properties/
and
spring-boot/configuration/src/main/java/io/reflectoring/configuration on GitHub
because I am working on utilizing it for the creation of custom properties on my Spring Boot application. Unfortunately, while the information you gave was pretty complete on how to use @ConfiguratioProperties to create configuration properties, there is one pretty major piece of information that is missing:
How do you access the properties once you have defined them and made Spring boot "aware" of them???
Using your properties as an example: you made the MailModuleProperties class to add the twp properties "enabled" and "defaultSubject", and you created two versions of the MailModuleConfiguration class to make a MailModuleProperties instance available to the Spring Boot application. Well and good, but how do you actually access and use the two properties once you make them together?
Suppose I want to create a Controller class with a @GetMapping annotated method that wraps the value of the "defaultSubject" property in some HTML and returns it to a client application or browser? How do I access the MailModuleProperties instance in order to get the property???
I did try to use the @value annotation to set a string to the value of defaultSubject for use in a Controller method, but the string was null when I attempted to use it.
Without that critical piece of information, your information about using @ConfigurationProperties is pretty unusable.
Can you please include an example of how one actually accesses and uses the properties you made in a Controller or Service class?
The text was updated successfully, but these errors were encountered: