jfinal集成druid监控,uri如何监控的到?

jfinal集成druid监控,sql什么的没有问题,就是uri如何监控起来?访问任何接口都没有URI监控数据

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
	<filter>
		<filter-name>jfinal</filter-name>
		<filter-class>com.jfinal.core.JFinalFilter</filter-class>
		<init-param>
			<param-name>configClass</param-name>
			<param-value>com.demo.common.DemoConfig</param-value>
		</init-param>
	</filter>
	
	<filter-mapping>
		<filter-name>jfinal</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<!-- 添加druid监控-->   
	<servlet>  
	    <servlet-name>DruidStatView</servlet-name>  
	    <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>  
	</servlet>  
	<servlet-mapping>  
	    <servlet-name>DruidStatView</servlet-name>  
	    <url-pattern>/druid/*</url-pattern>  
	</servlet-mapping>
	<!-- 添加Web应用等监控-->  
	<filter>
	    <filter-name>DruidWebStatFilter</filter-name>
	    <filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>
	    <init-param>
	        <param-name>exclusions</param-name>
	        <param-value>*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*</param-value>
	    </init-param>
	</filter>
	<filter-mapping>
	    <filter-name>DruidWebStatFilter</filter-name>
	    <url-pattern>/*</url-pattern>
	</filter-mapping>
</web-app>
public static DruidPlugin createDruidPlugin() {
		 DruidPlugin dp = new DruidPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password").trim());
		// 1.统计信息插件
		   StatFilter statFilter = new StatFilter();
		   statFilter.setMergeSql(true);
		   statFilter.setLogSlowSql(true);
		   // 慢查询目前设置为1s,随着优化一步步进行慢慢更改
		   statFilter.setSlowSqlMillis(1500);
		   dp.addFilter(statFilter);
		   // 2.日志插件
		   // 保存DruidDataSource的监控记录,设置打印日志周期,默认使用DruidDataSourceStatLoggerImpl
		   // DruidPlugin未暴露setTimeBetweenLogStatsMillis(),只能使用properties方法设置
		   // 3.防注入插件
		   WallFilter wall = new WallFilter();
		   wall.setDbType("mysql");
		   dp.addFilter(wall);
		   return dp;
	}
	
	/**
	 * 配置插件
	 */
	public void configPlugin(Plugins me) {
		// 配置C3p0数据库连接池插件
		DruidPlugin druidPlugin = createDruidPlugin();
		
		// 配置log插件
		Log4jFilter logFilter = new Log4jFilter();
		logFilter.setStatementLogEnabled(false);
		logFilter.setStatementLogErrorEnabled(true);
		logFilter.setStatementExecutableSqlLogEnable(true);

		druidPlugin.addFilter(logFilter);
		
		me.add(druidPlugin);
		// 配置ActiveRecord插件
		ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
		// 所有映射在 MappingKit 中自动化搞定
		_MappingKit.mapping(arp);
		me.add(arp);
	}

blob.png

评论区

抖抖抖

2018-05-17 10:53

顶起来~

JFinal

2018-05-17 11:09

这个只需要按照 druid 官方档去做就可了, jfinal 整合的 druid 提供的整合可以当做不存在

因为 jfinal 对 druid 的整合只是方便获取 DataSource 而已,其它的事情不参与

抖抖抖

2018-05-17 11:43

@JFinal 好的,谢谢回复

热门反馈

扫码入社