skip to Main Content

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.

3

Answers


  1. 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.

    Login or Signup to reply.
  2. Putting the data in the application.properties and having a component a class to set the data using the @Value annotation. This ensures sensitive data can be feed in through the environment.

    Login or Signup to reply.
  3. You can use @Configuration with @Profile if you want to but that might be complicating stuff. You can instead document these properties maybe in a JSON file in the your resource directory.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search