Java – how to use spaces in the parameters of Maven 2 exec plug-in

Related questions: Maven exec plugin not reading configuration

In my configuration, I need a parameter, which is a file path I found a rather "dirty" solution around the quotation marks of the parameters in POM ("dirty", because the parameters will be passed to the main method and these quotation marks, they must be deleted again in the code)

<configuration>
    <executable>java</executable>
    <arguments>
        <argument>"path to file"</argument>
    </arguments>
</configuration>

However, I found no solution to pass the path as a command-line parameter:

>mvn exec:java -Dexec.args="path to file"

Solution

In general, Maven requires the entire parameter to be referenced if there are spaces in the parameter value

mvn exec:java "-Dexec.args=path to file"
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>