Search code examples
javaspring-bootclasspathapplication.properties

Should I use an application.properties or create an alone file for huge fields?


We work on a huge application and it is integrated with more external APIs. So we use more static fields

key <=> value

To integrate with only one system like PayPal payment for instance.

Fields

payment.paypal.live-mode=false
payment.paypal.url.charge=xxxxxxx
payment.paypal.url.redirect=xxxx
payment.paypal.url.exchange=xxxx
payment.paypal.secret-key= xxxx
payment.paypal.publishable-key= xxxxx
payment.paypal.sources=xxxx,xxx,xxx,xxx
and more fields

What is the best practice to use? Application.properties or create a new JSON file that handles all these fields.

Note that:- The application has more than one profile.


Solution

  • Maybe in your case, it makes sense to have a separate file to handle long and specific configurations that are somewhat core to your application. The downside of this is that you would need to handle its parsing on your own (with the help of Jackson for example).

    You might also consider using yaml files instead of properties since at least it would avoid repetitions such as payment.paypal.url and it is easier to read and organize.