为了账号安全,请及时绑定邮箱和手机立即绑定

如何使用Maven执行程序?

如何使用Maven执行程序?

慕后森 2019-12-13 09:28:00
我想让Maven目标触发Java类的执行。我正在尝试通过以下方式进行迁移Makefile:neotest:    mvn exec:java -Dexec.mainClass="org.dhappy.test.NeoTraverse"我想mvn neotest提出make neotest目前的工作。无论是Exec插件的文件,也不是Maven的Ant任务的网页有任何形式的简单例子。目前,我在:<plugin>  <groupId>org.codehaus.mojo</groupId>  <artifactId>exec-maven-plugin</artifactId>  <version>1.1</version>  <executions><execution>    <goals><goal>java</goal></goals>  </execution></executions>  <configuration>    <mainClass>org.dhappy.test.NeoTraverse</mainClass>  </configuration></plugin>不过,我不知道如何从命令行触发插件。
查看完整描述

2 回答

?
慕田峪9158850

TA贡献1794条经验 获得超7个赞

为了执行多个程序,我还需要一个profiles部分:


<profiles>

  <profile>

    <id>traverse</id>

    <activation>

      <property>

        <name>traverse</name>

      </property>

    </activation>

    <build>

      <plugins>

        <plugin>

          <groupId>org.codehaus.mojo</groupId>

          <artifactId>exec-maven-plugin</artifactId>

          <configuration>

            <executable>java</executable>

            <arguments>

              <argument>-classpath</argument>

              <argument>org.dhappy.test.NeoTraverse</argument>

            </arguments>

          </configuration>

        </plugin>

      </plugins>

    </build>

  </profile>

</profiles>

然后可以执行以下命令:


mvn exec:exec -Dtraverse


查看完整回答
反对 回复 2019-12-13
  • 2 回答
  • 0 关注
  • 514 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信