简体   繁体   English

VisualVM可以用于分析Maven项目吗? 如果是,那怎么办?

[英]Can VisualVM be used for profiling Maven Projects? If yes then how?

I want to profile a Maven project using JVisualVM. 我想使用JVisualVM来分析Maven项目。 In eclipse in the run configurations there is nothing for running the maven build in VisualVm. 在Eclipse中,在运行配置中,没有任何内容可以在VisualVm中运行Maven构建。 Next I tried running the VisualVM application and profiling the projects, the jar files that get created when I do mvn -install were my choice of input. 接下来,我尝试运行VisualVM应用程序并分析项目,执行mvn -install时创建的jar文件是我选择的输入。 However, even those don't really work. 但是,即使是那些并没有真正起作用。

Is there a way to generate a FUNCTIONAL profile of a maven project. 有没有一种方法可以生成Maven项目的功能概要文件。 I dont want to know the CPU usage and stuff, rather I am interested in the execution flow of the project ie how the methods are being called and executed and when/where are they interacting (basically TRACE of the program). 我不想知道CPU的使用情况和东西,而是对项目的执行流程感兴趣,例如,如何调用和执行方法以及它们在何时/何处进行交互(基本上是程序的TRACE)。

If there are some other tools also please feel free to suggest. 如果还有其他工具,请随时提出建议。

Maven is a build tool . Maven是一个构建工具 VisualVM profiles Java processes . VisualVM对Java 进程进行概要分析 A running process can be built with Maven and profiled with VisualVM, but they have no relation to each other. 可以使用Maven构建运行中的进程,并使用VisualVM对其进行概要分析,但是它们之间没有任何关系。 VisualVM is a profiler, it's not used to trace the execution of a program except for hotspots caught by the profiler. VisualVM是探查器,除探查器捕获的热点外,它不用于跟踪程序的执行。

If you want to trace maven itself, use the -X argument. 如果要跟踪Maven本身,请使用-X参数。

mvn -X clean install

It's not a profile, but that's what "the execution flow of the project ie how the methods are being called and executed" means at build time. 它不是概要文件,而是在构建时项目的执行流程,即如何调用和执行方法”的含义。

If you want to actually profile your program at runtime (not maven), then the fact that it was built with maven, ant or gradle does not matter. 如果你想在运行时实际分析您的程序(没有Maven的),那么,事实上,它是使用Maven构建,蚂蚁或gradle这个不要紧。 You need to foresee something in your own code to log the information (tools may be available depending on the libraries you use). 您需要预见自己的代码中的某些内容才能记录信息(根据所使用的库,工具可能可用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM