In our project we are using Lightbend Config / TypesafeConfig.
I can run my program with java -jar
. The configuration of my program can also be done by using command line parameters.
Example:
java -jar simpleclient.jar -Dservice.url="http://localhost:8123"
Now I introduced https://picocli.info/ to have a better command line handling for my application.
The problem I'm facing now ist, that picocli doesn't allow the usage of -D... parameters in the standard configuration.
How can this be changed?
When you say “picocli doesn’t allow the use of -D... options”, I assume you mean you want to allow end users to set system properties with the
-Dkey=value
syntax. When such parameters are passed to the application, the application needs to use these values to set system properties, as shown below.First, users can set system properties by passing
-Dkey=value
parameters to thejava
process instead of to the main class in the jar. In the below invocation, the system properties are set directly and are not passed as parameters to the application:Secondly, you can define a
-D
option in your application that sets system properties: