當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
java spring druid_Spring配置Druid连接池
生活随笔
收集整理的這篇文章主要介紹了
java spring druid_Spring配置Druid连接池
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
最近項目用c3p0數據連接池有問題,因此換成了druid連接池,它的優點是可以很好的監控DB池連接和SQL的執行情況。在此做個記錄便于下次使用。
1、首先導入Spring(網上很多這里我就不列舉了)和Druid(druid-1.0.9.jar)的相關jar包
2、在web.xml中搭建Spring和Druid的環境
org.springframework.web.context.ContextLoaderListener
DruidStatView
com.alibaba.druid.support.http.StatViewServlet
DruidStatView
/druid/*
3、在Spring-servlet.xml中配置druid數據連接池
4、編寫java文件
@Service
public class JdbcServiceBean {
protected SimpleJdbcTemplate simpleJdbcTemplate;
@Resource(name = "dataSource")
public void setDataSource(DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
}
}
總結
以上是生活随笔為你收集整理的java spring druid_Spring配置Druid连接池的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 远卓:数字化转型的精益化思考
- 下一篇: 第5章 Python 数字图像处理(DI