1

我想使用来自 maven 的参数执行一个 jar 文件。下面列出了我要执行的命令。我perf4j在依赖项中有jar文件。该times.log文件在他们的文件系统中。

java -jar perf4j-0.9.16.jar times.log

谢谢

4

4 回答 4

3

你可能想看看@ exec-maven-plugin

于 2012-06-14T20:33:07.517 回答
1

第一的

mvn clean install

mvn exec:java -Dexec.mainClass="com.java.App" -Dexec.args="Args"
于 2017-04-17T12:49:56.997 回答
0

你真正想做的是什么?使用 jar(这是一个依赖项)来监控您的应用程序?

你看过maven exec 插件吗?

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
          <execution>
            ...
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <executable>maven</executable>
          <!-- optional -->
          <workingDirectory>/tmp</workingDirectory>
          <arguments>
            <argument>-X</argument>
            <argument>myproject:dist</argument>
            ...
          </arguments>
        </configuration>
      </plugin>
    </plugins>
  </build>
   ...
</project>
于 2012-06-14T20:36:33.677 回答
0

我看过 maven exec 插件,但不确定如何以及在哪里指定 jar 文件名,因此感谢您的回复,但我正在查看更多信息,尤其是 jar 文件。通过一些试验和错误,以下工作。我必须从 jar 文件中找到要使用的主类。mvn install运行该文件并产生以下输出:

 <build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>install</phase>
                    <goals>
                        <goal>java</goal>
                    </goals>
                    <configuration>
                        <mainClass>org.perf4j.LogParser</mainClass>
                        <arguments>
                            <argument>InlineLogging.log</argument>
                        </arguments>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>org.perf4j</groupId>
        <artifactId>perf4j</artifactId>
    </dependency>
</dependencies>
于 2012-06-15T02:27:17.450 回答