如何使用JProfiler在Windows上配置maven测试?

时间:2018-04-30 21:27:58

标签: maven jprofiler

我试过这个

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <excludedGroups>com.my.test.IntegrationTest</excludedGroups>
      <argLine>-agentpath:C:\Program Files\jprofiler10\bin\windows-x64\jprofilerti.dll=port=8849,nowait</argLine>
    </configuration>
  </plugin>

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <configuration>
      <groups>com.my.test.IntegrationTest</groups>
      <argLine>-agentpath:C:\Program/ Files\jprofiler10\bin\windows-x64\jprofilerti.dll=port=8849,nowait</argLine>
    </configuration>
    <executions>

导致

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project my-util: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_162\jre\bin\java" -agentpath:C:\Program Files\jprofiler10\bin\windows-x64\jprofilerti.dll=port=8849,nowait -jar C:\Users\xeno\IdeaProjects\my-util\target\surefire\surefirebooter6221605500745834451.jar C:\Users\xeno\IdeaProjects\my-util\target\surefire\surefire4500791091163286071tmp C:\Users\xeno\IdeaProjects\my-util\target\surefire\surefire_07989865501871806496tmp"

如果它在可用时自动开始在UI中录制

,则获得奖励积分

1 个答案:

答案 0 :(得分:1)

传递

-agentpath:<path to jprofilerti.dll>=port=8849,nowait

将只加载配置文件代理但不执行任何记录。在您的情况下,还有另一个问题,因为JVM无法启动,很可能C:\Program Files中的空间将参数拆分为两个参数。我建议将JProfiler安装到没有空格的路径中。

要记录数据并保存快照,您必须配置脱机配置文件。这个论点看起来像这样:

-agentpath:<path to jprofilerti.dll>=port=8849,offline,id=<session ID>

其中会话ID取自会话设置对话框中“应用程序设置”选项卡的右上角。在该会话中,您将配置“JVM启动”触发器以开始记录数据,并配置“JVM退出”触发器以在最后保存快照。