标签:导出 ann led dep 生成 esc Servle 格式 script
1.引入JavaMelody监控插件的依赖
<!-- java系统监控插件 --> <dependency> <groupId>net.bull.javamelody</groupId> <artifactId>javamelody-core</artifactId> <version>1.86.0</version> </dependency>
2.如果需要对监控数据进行导出操作,可引入itext导出PDF文件,依赖如下:
<!--JavaMelody监控PDF格式文件导出--> <dependency> <groupId>com.lowagie</groupId> <artifactId>itext</artifactId> <version>2.1.7</version> </dependency>
3.生成系统监控配置
package com.hierway.taskm.config; import net.bull.javamelody.MonitoringFilter; import net.bull.javamelody.Parameter; import net.bull.javamelody.SessionListener; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * @Author: lyric * @Description: Java系统监控配置 * @Date: Created in 2020-11-12 11:02 */ @Configuration public class JavaMelodyConfiguration { @Bean public FilterRegistrationBean monitorFilter(){ FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new MonitoringFilter()); filterRegistrationBean.addUrlPatterns("/*"); filterRegistrationBean.addInitParameter(Parameter.QUARTZ_DEFAULT_LISTENER_DISABLED.getCode(), Boolean.TRUE.toString()); filterRegistrationBean.addInitParameter(Parameter.AUTHORIZED_USERS.getCode(), "admin:pwd"); return filterRegistrationBean; } @Bean public ServletListenerRegistrationBean sessionListener(){ ServletListenerRegistrationBean servletListenerRegistrationBean = new ServletListenerRegistrationBean(); servletListenerRegistrationBean.setListener(new SessionListener()); return servletListenerRegistrationBean; } }
4.启动项目,采用 ip:port/monitoring 访问监控页面,如:localhost:8080/monitoring
Spring Boot项目中使用JavaMelody对项目性能进行监控
标签:导出 ann led dep 生成 esc Servle 格式 script
原文地址:https://www.cnblogs.com/Skylers/p/14048827.html