Druid+SSM+可视化监控界面

先看效果:

Druid+SSM+可视化监控界面_第1张图片

关键步骤说明:

前提条件,自己先搭建一个ssm框架,然后再继续下面的步骤

1.导入jar包

 0.2.23  

 
    com.alibaba
    druid
    ${druid.version}
      

2.配置数据源

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/srnswx?characterEncoding=utf-8
jdbc.username=root
jdbc.password=123456

druid.initialSize=10
druid.minIdle=10
druid.maxActive=50
druid.maxWait=60000
druid.timeBetweenEvictionRunsMillis=60000
druid.minEvictableIdleTimeMillis=300000
druid.validationQuery=SELECT 'x'
druid.testWhileIdle=true
druid.testOnBorrow=false
druid.testOnReturn=false
druid.poolPreparedStatements=true
druid.maxPoolPreparedStatementPerConnectionSize=20
druid.filters=stat
   
          
          
          
          
        
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		  
      

3.配置web.xml

 
	
		DruidWebStatFilter
		com.alibaba.druid.support.http.WebStatFilter
		true
		
			exclusions
			/static/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*
		
		
			sessionStatMaxCount
			1000
		
	
	
		DruidWebStatFilter
		/*
	

	
	
		DruidStatView
		com.alibaba.druid.support.http.StatViewServlet
		true
	
	
		DruidStatView
		/druid/*
	

4.编写controller

package com.demo.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/druid")
public class DruidController {
	@RequestMapping("/index")
	public String index(Model model, HttpServletRequest request) {
		return "durid/index";
	}

}
到这里就完成了,http://localhost:8080/.../druid/index  就ok了。  

你可能感兴趣的:(后端编程)