4.4.1 (TASK) Injecting Custom App Properties
4.4.1 (TASK) Injecting Custom App Properties
By:MadSe
Application and Benefits of
Injecting Properties
By:MadSe
• Externalizing Configuration
• Environment-Specific Settings
By:MadSe
• Database Configuration
• API Endpoints
By:MadSe
• Feature Toggles
By:MadSe
TASK Injecting Custom
Application Properties
By:MadSe
• Objective :
• Steps :
By:MadSe
Making a Copy out of Previous App
By:MadSe
• As given above, access the “commandline” project properties.
• Get the application folder path.
• Open the path in Windows File Explorer and create a copy
• Rename it to “custom_properties”
• Open the project in Net Beans again.
• NOTE : Only the folder name is changed. The name of the
project will remain the same.
By:MadSe
Injecting Properties in
“application.properties”
By:MadSe
• #11 - #12 Inserting our custom properties in “application.properties” file
By:MadSe
Injecting Properties in
Spring Boot Controller and Exposing
Endpoint
By:MadSe
• #5 Importing “@Value” annotation from the Spring Framework
• #13 - #18 Storing custom property values in variable names by annotating
them with”@Value”
By:MadSe
• #5 Importing “@Value” annotation from the Spring Framework
• #13 - #18 Storing custom property values in variable names by annotating them
with”@Value”
• #20 - #24 Exposing endpoint “/teaminfo” that will fetch the custom properties
info NEXT, running the app
By:MadSe
• Make sure to open the main application java file as given above Right-click
Run File Check out the output next
By:MadSe
• Above, accessing the endpoint successfully to display the custom properties.
By:MadSe