I am confused about the correct way to set the property for some unit tests through the command line when using Maven. There are a number of issues (for example, Task memory parameter Maven without installing variable MAVEN_OPTS environment , is there a way to transfer jvm args from the command line in the maven? , How to set the JVM parameters for test Junit Unit? ), Which relate to this topic, but no one has the answer I'm looking for.
I want to set a property java.util.logging.config.classfor some value, but I do not want to set an environment variable MAVEN_OPTS.
I can configure the surefire plugin in my pom file with the property:
<argLine>-Djava.util.logging.config.class=someClass</argLine>
so that it is installed every time the test phase is performed.
However, if I remove the parameter from the pom file and add the following to the command line:
mvn package -DargLine="java.util.logging.config.class=someClass"
then the following error is reported during the testing phase and the assembly fails:
Error: could not find or load the main class java.util.logging.config.class = someClass
If I run the following from the command line:
mvn package -Djava.util.logging.config.class=someClass
then at the beginning of the assembly the following error is reported, but the assembly and tests are successful:
Failed to create logging configuration class "someClass" java.lang.ClassNotFoundException: someClass
I do not really understand the behavior. Can someone enlighten me?