Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical information missing in your Properties example #300

Open
RobertBrown3 opened this issue Mar 5, 2024 · 0 comments
Open

Critical information missing in your Properties example #300

RobertBrown3 opened this issue Mar 5, 2024 · 0 comments

Comments

@RobertBrown3
Copy link

RobertBrown3 commented Mar 5, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant