如何将命令行参数传递给Maven程序的执行?

我正在eclipse中工作。

我的Maven程序有一个带exec插件的pom.xml文件:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>${maven.exec.plugin.version}</version>
    <configuration>
        <arguments>
            <argument>src/test/resources/file.txt</argument>
        </arguments>
        <executable>mvn</executable>
        <mainClass>${main.class}</mainClass>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
</plugin>

我试图传递一个参数,但是我继续遇到错误:

  

未知生命周期阶段“。\ src \ test \ resources \ file.txt”。您必须以:或:[:]:格式指定有效的生命周期阶段或目标。可用的生命周期阶段包括:验证,初始化,生成源,流程源,生成资源,流程资源,编译,流程类,生成测试源,流程测试源,生成测试资源,流程测试资源,测试编译,过程测试类,测试,准备打包,打包,集成前测试,集成测试,集成后测试,验证,安装,部署,预清洁,清洁,清理后,站点前,站点,站点后,站点部署。 -> [帮助1]

我还尝试通过运行方式->运行配置,通过eclipse中的命令行参数传递文件。我收到相同的错误消息。

如何将输入文件参数传递给应用程序?

seasun19880923 回答:如何将命令行参数传递给Maven程序的执行?

我刚刚在尝试从 OpenJFX.io 运行 Getting Started 教程时遇到了同样的错误。我遇到问题的具体地方是在配置和运行模块化 MAVEN 项目的部分,第 5 步“运行项目”。说明如下:

点击 Run -> Run As -> Maven Build -> New launch configuration to 创建新配置。将其命名为hellofx,并添加所需的 目标:

clean javafx:run

我省略了这一步,因为我找不到输入目标的位置。运行然后生成相同的错误。

我忽略了运行配置有一个标记为“目标”的字段。它位于屏幕中间的“主要”选项卡上。在此字段中输入所需文本后,“hellofx”教程就可以正常运行。

如果“目标”字段未显示在项目的运行配置中,我猜如果您通过选择“Maven 构建”选项创建新的运行配置,它会出现。

AFAIK,我的 Spring Tool Suite 4 基于 Eclipse,Maven 方面将类似,允许版本随时间演变。

,

向您的POM添加类似于以下内容的配置:

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="*" />
    <RowDefinition Height="*" />
  </Grid.RowDefinitions>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*" />
  </Grid.ColumnDefinitions>

 //set them in the same Row and Column and they will be in the same position .
  <Image Source="image1.png" Grid.Row="0" Grid.Column="0"></Image>
  <Frame BackgroundColor="#fedb0a" HasShadow="False"Grid.Row="0" Grid.Column="0">
   //...
  </Frame>

  //...other elements

</Grid>

Source

本文链接:https://www.f2er.com/3152568.html

大家都在问