将多个参数传递给maven

时间:2018-03-04 03:58:01

标签: java maven

我写了一个简单的cli程序,以便在调用时从CLI获取输入。我可以通过在pom.xml中添加exec插件来实现这一点

          <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.1.1</version>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>com.mavericks.App</mainClass>
                            <arguments>
                                <argument>names.txt</argument>
                                <argument>expense.txt</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

但是当我尝试通过cli

调用同样的东西时
mvn exec:java -Dexec.mainClass=“com.mavericks.App” -Dexec.args=“'names.txt' 'expense.txt'”

未知生命周期阶段“expense.txt”“。您必须指定有效的生命周期阶段或目标。非常感谢帮助。

1 个答案:

答案 0 :(得分:1)

根据slinlok的评论,它适用于上述修改,

mvn exec:java -Dexec.mainClass=com.mavericks.App -Dexec.args="names.txt expense.txt"

感谢。

相关问题