logo资料库

Spring整合Druid Druid 最好的链接池 Druid能够提供强大的监控和扩展功能。.docx

第1页 / 共3页
第2页 / 共3页
第3页 / 共3页
资料共3页,全文预览结束
Druid 是 Java 语言中最好的数据库连接池。Druid 能够提供强大的监控和扩展功能。 1: maven 引入 druid 版本号 1.1.9/spring 版本号 4.2.1 druid com.alibaba ${druid-version} 2:找到配置链接的 sessionFactory 修改 dataSource 为 druidDataSource com.accenture.automation.module.te.lawsonte.domain.entity. com.accenture.automation.module.te.common.entity. com.accenture.automation.module.te.common.masterdata. com.accenture.automation.module.te.common.history. ${hibernate.hbm2ddl.auto} ${commondb.dialect} ${hibernate.show_sql} 3:spring 和 jdbc 的关联监控 com.accenture.automation.module.te.*.*.service.*
初 始 化 大 小 、 最 小 、 最 大 --> 4:配置_DruidDataSource 参考配置 name="url" value="${jdbc_url}" /> /> name="minEvictableIdleTimeMillis" value="300000" /> name="validationQuery" value="SELECT 'x'" /> value="true" /> name="testOnReturn" value="false" /> PSCache 的 大 小 --> - 配置监控统计拦截的 filters --> 5:启动监控页面 配置 web.xml StatViewServlet 是一个标准的 javax.servlet.http.HttpServlet,需要配置在你 web 应用中的 WEB-INF/web.xml 中。 DruidStatView com.alibaba.druid.support.http.StatViewServlet DruidStatView /druid/* DruidWebStatFilter com.alibaba.druid.support.http.WebStatFilter
exclusions *.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/* profileEnable true principalCookieName USER_COOKIE principalSessionName USER_SESSION DruidWebStatFilter /* 根据配置中的 url-pattern 来访问内置监控页面,如果是上面的配置,内置监控 页面的首页是/druid/index.html 例如: http://110.76.43.235:9000/druid/index.html http://110.76.43.235:8080/mini-web/druid/index.html ps:如果监控页面没数据可能是 csrf 拦截了 druid 的请求 /**/TE/common/*.do /**/TE/audit/messageInfo/*.do /**/druid/* <-- 增加配置 --> 6:Github 项目地址 详细说明 https://github.com/alibaba/druid
分享到:
收藏