Morning, I have created a small spring application which can be bundled together and run as a jar file on the command line.

It takes several arguments which determine how the application works, runs etc.

I have two persistence implementations MongoDB and JDBC/MySQL both with implement the same interface and thus can be inter-changeable in the calling services.

The user of the application simply passes a different flag to the jar file when ran to specify a different implementation.

My question:

What is the advised or best practice way of wiring up/ setting the correct persistence implementation on a service depending on the arguments passed in?

I have this working as it stands but don't like the implementation and I'm sure there is a better way. I simply have a façade with both implementation wired in, then depending on the arguments passed in I call a different implementation.

Cheers, James