小编dec*_*raj的帖子

在mvn exec:exec中传递命令行参数

令我感到惊讶的是,本来应该是一项非常轻松的工作对我来说是一项非常烦人的任务.我需要的是将几个命令行参数传递给我的maven exec:exec插件.不幸的是,几个小时的谷歌搜索根本没有帮助.

这是我的插件

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2</version>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-instrument</artifactId>
            <version>${spring.version}</version>
        </dependency>
    </dependencies>
    <configuration>
        <executable>java</executable>
        <arguments>
            <argument>-classpath</argument>
            <classpath />
            <argument>-javaagent:${settings.localRepository}/org/springframework/spring-instrument/${spring.version}/spring-instrument-${spring.version}.jar</argument>
            <argument>-Xmx256m</argument>
            <argument>com.myPackage.Myclass</argument>
        </arguments>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

现在从命令提示符我输入

mvn exec:exec -Dexec.args=-Dmy.property=myProperty
Run Code Online (Sandbox Code Playgroud)

我也试过了

mvn exec:exec -Dexec.arguments=-Dmy.property=myProperty
Run Code Online (Sandbox Code Playgroud)

还有很多其他的东西.但似乎没有任何工作.我知道exec:exec运行在一个单独的VM中,但根据文档-Dexec.args应该适合我.有人可以建议我哪里出错了???

maven-plugin

29
推荐指数
3
解决办法
4万
查看次数

标签 统计

maven-plugin ×1