Spring Boot项目中使用JavaMelody对项目性能进行监控
2021-03-13 19:29
标签:导出 ann led dep 生成 esc Servle 格式 script 1.引入JavaMelody监控插件的依赖 2.如果需要对监控数据进行导出操作,可引入itext导出PDF文件,依赖如下: 3.生成系统监控配置 4.启动项目,采用 ip:port/monitoring 访问监控页面,如:localhost:8080/monitoring Spring Boot项目中使用JavaMelody对项目性能进行监控 标签:导出 ann led dep 生成 esc Servle 格式 script 原文地址:https://www.cnblogs.com/Skylers/p/14048827.html
dependency>
groupId>net.bull.javamelodygroupId>
artifactId>javamelody-coreartifactId>
version>1.86.0version>
dependency>
dependency>
groupId>com.lowagiegroupId>
artifactId>itextartifactId>
version>2.1.7version>
dependency>
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;
}
}
文章标题:Spring Boot项目中使用JavaMelody对项目性能进行监控
文章链接:http://soscw.com/essay/64244.html