Specifying a default argument in pom.xml and overriding it in the command line

The only function of my main class is to read from an xml config file, which I’m currently specifying in the command line. Is it possible to make it so a default config file is specified in pom.xml, so if the program is run from the command line without passing in an argument, that config file is read, but if an argument is passed in with -Dexec.args the default is overridden?

at first look at exec plugin documentation here

in your maven in properties specify your default property which you want look at my.custom.property

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


        <!-- frameworks -->

        <!-- properties -->



here is java class

package test;

import java.util.stream.Stream;

public class Test {

    public static void main(String[] args) {
                .forEach(arg -> System.out.println("ARGUMENT " + arg));

and if you execute mvn compile exec:java you should see somewhere outpu ARGUMENT MAVEN. If you provide your own argument eg. mvn compile exec:java -Dmy.custom.property=TEST you should see ARGUMENT TEST somewhere in console.