Druid Springboot中的使用
添加监控页面
1.添加引用
com.alibaba
druid-spring-boot-starter
release
2.添加日志监控过滤器
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
import com.alibaba.druid.support.http.WebStatFilter;
@WebFilter(filterName = "druidWebStatFilter",urlPatterns = "/*",
initParams = {
@WebInitParam(name="exclusions",value="*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*")
})
public class DruidStatFilter extends WebStatFilter {
}
3.添加日志监控ViewServlet类
import com.alibaba.druid.support.http.StatViewServlet;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
@WebServlet(urlPatterns = "/druid/*",
initParams = {
@WebInitParam(name = "allow",value=""),
@WebInitParam(name="loginUsername",value="admin"),
@WebInitParam(name="loginPassword",value="123456"),
@WebInitParam(name="resetEnable",value="false")
})
public class DruidStatViewServlet extends StatViewServlet {
private static final long serialVersionUID = -2688872071445249539L;
}
4.启动项添加注解
@ServletComponentScan(value="packageSrc")
5.访问日志监控页面
http://[project ip]:[port]/druid/index.html
Druid相关参数
转载自【乌云de博客】: