【问题标题】:Maven project how run from cmd line passing argumentMaven项目如何从命令行传递参数运行
【发布时间】:2018-03-28 03:33:33
【问题描述】:

我想从 cmd 行运行我的 mavn 项目,传递参数“https://s3.amazonaws.com/dept-dev-swrve/full_stack_programming_test/test_data.csv.gz

这是 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.programming.test</groupId>
    <artifactId>csv_parser</artifactId>
    <version>1.0-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>Main</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <finalName>executable</finalName>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id> <!-- this is used for inheritance merges -->
                        <phase>package</phase> <!-- bind to the packaging phase -->
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8.21</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

代码编译正常,但现在我想从命令行运行并传递一个参数。我怎样才能做到这一点 ?

【问题讨论】:

    标签: maven maven-2 maven-3


    【解决方案1】:

    您可以根据插件的目标设置 -D 参数。 例如

    mvn -DskipTests=true,其中skipTests是一个目标,=True是它的价值。

    【讨论】:

      猜你喜欢
      • 2012-04-23
      • 2014-05-04
      • 2011-04-10
      • 2013-05-08
      • 2017-06-06
      • 2017-08-17
      • 2013-04-03
      • 2021-09-29
      • 2011-12-18
      相关资源
      最近更新 更多