Springboot整合javamelody

直接上配置代码:

新建类:

JavamelodyConfiguration.java

代码如下:

import net.bull.javamelody.MonitoringFilter;
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: TEST
 * @Date: 2018/6/10 22:11
 * @Description: JAVAMELODY监控配置
 */
@Configuration
public class JavamelodyConfiguration {

    @Bean
    public FilterRegistrationBean monitorFilter(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new MonitoringFilter());
        filterRegistrationBean.addUrlPatterns("/*");
        return filterRegistrationBean;
    }

    @Bean
    public ServletListenerRegistrationBean sessionListener(){
        ServletListenerRegistrationBean servletListenerRegistrationBean = new ServletListenerRegistrationBean();
        servletListenerRegistrationBean.setListener(new SessionListener());
        return servletListenerRegistrationBean;
    }

}


引入POM.xml


			net.bull.javamelody
			javamelody-core
			1.72.0
		


启动应用,访问:http://localhost/b/monitoring,即可.

你可能感兴趣的:(Springboot整合javamelody)