我想使用来自 maven 的参数执行一个 jar 文件。下面列出了我要执行的命令。我perf4j
在依赖项中有jar文件。该times.log
文件在他们的文件系统中。
java -jar perf4j-0.9.16.jar times.log
谢谢
我想使用来自 maven 的参数执行一个 jar 文件。下面列出了我要执行的命令。我perf4j
在依赖项中有jar文件。该times.log
文件在他们的文件系统中。
java -jar perf4j-0.9.16.jar times.log
谢谢
你可能想看看@ exec-maven-plugin
第一的
mvn clean install
比
mvn exec:java -Dexec.mainClass="com.java.App" -Dexec.args="Args"
你真正想做的是什么?使用 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>
我看过 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>