Issue
I encountered handful of guides to creating spring data jpa projects and people configured persistence layer using properties file and javaconfig both. If we one uses javaconfig why would they even bother to create another properties file to include configurations? If one strategy is used(i.e. JavaConfig) to configure project , what is the use of the other (i.e. properties file) strategy? Do I have a misunderstanding as to how to configure projects?
Solution
JavaConfig was mostly used for old version of Java
or legacy projects. It is a helper library used to avoid the boiler plate needed to write a code to open the properties
file and map the values directly to a class that can represent your properties in memory.
With JavaConfig
your code will looks like this and without it, your code will look like this.
If one strategy is used(i.e. JavaConfig) to configure project , what is the use of the other (i.e. properties file) strategy? Do I have a misunderstanding as to how to configure projects?
Properties
file, is the standard used in Java
to store external configuration values. It is a key/value file, example: application.properties or application.yml are used in modern framework such as Spring
, that offer a simple way to manage your properties file.
Answered By - Harry Coder
Answer Checked By - Senaida (JavaFixing Volunteer)