JBolt开发平台数据库连接池是Druid。
最近需要配置上Druid自带的监控。
这是DruidPlugin的相关配置代码:
//配置数据库连接池插件
DruidPlugin dbPlugin=new DruidPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password"));
// 配置防火墙加强数据库安全
WallFilter wallFilter = new WallFilter();
wallFilter.setDbType(JdbcConstants.MYSQL);
dbPlugin.addFilter(wallFilter);
//配置监控
StatFilter statFilter=new StatFilter();
statFilter.setMergeSql(true);
statFilter.setLogSlowSql(true);
statFilter.setSlowSqlMillis(1500);
// 添加 StatFilter 才会有统计数据
dbPlugin.addFilter(statFilter);
me.add(dbPlugin);在全局Handler配置里,增加对Druid监控的配置与权限判断,因为这个监控界面不是谁都能看的,后台需要分配权限给用户。
DruidStatViewHandler dvh = new DruidStatViewHandler("/admin/druid/monitor",//设置访问路径
new IDruidStatViewAuth(){
public boolean isPermitted(HttpServletRequest request) {
//从session中拿到用户信息,如果使用ThreadLocal,就从ThreadLocal里拿
HttpSession hs = request.getSession(false);
if(hs==null) {
return false;
}
//拿到用户userId
Object userId=hs.getAttribute(SessionKey.ADMIN_USER_ID);
if(userId==null||userId.toString().equals("0")) {
return false;
}
//通过权限判断工具类判断此用户是否有PermissionKey.DRUID_MONITOR这个权限
return UserAuthKit.hasPermission(Integer.parseInt(userId.toString()), true, PermissionKey.DRUID_MONITOR);
}
});
me.add(dvh);这样就可以在浏览器中访问http://localhost/admin/druid/monitor进入监控界面

如果没有分配权限就这样了

推荐:
【记录】navicat去连接oracle11g时报错处理记录
【分享】一个JFinal自身实现权限系统的建设思路(JFinal拦截器版)
【视频教程】基于JFinal-undertow的项目打包与部署(linux centos7)
【技术】Nginx加Undertow/Tomcat部署中的Proxy设置
JBolt开发平台全部教程:
JBolt插件安装和使用
https://ke.qq.com/course/354301?taid=2870150550611965&tuin=363b45b8
JFinal-JBolt开发平台从入门到精通-系列教程
https://www.jianshu.com/p/a18b61aa298a
JBolt开发平台入门(13)-自动化组件 autocomplete
https://my.oschina.net/imhoodoo/blog/3102509
JBolt开发平台入门(14)-四种主从表管理操作方式
https://my.oschina.net/imhoodoo/blog/3104717
JBolt开发平台入门(15)- 上下结构主从表管理简单实现
https://my.oschina.net/imhoodoo/blog/3106285