{"id":1794,"date":"2019-03-09T10:00:35","date_gmt":"2019-03-09T02:00:35","guid":{"rendered":"https:\/\/coderbee.net\/?p=1794"},"modified":"2019-03-11T20:45:30","modified_gmt":"2019-03-11T12:45:30","slug":"springboot-druid-%e8%b8%a9%e5%9d%91%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/coderbee.net\/index.php\/framework\/20190309\/1794","title":{"rendered":"SpringBoot druid \u8e29\u5751\u7b14\u8bb0"},"content":{"rendered":"<p>\u8fd9\u662f\u4e00\u4e2a\u540c\u4e8b\u78b0\u5230\u7684\u6848\u4f8b\u3002<\/p>\n<h2>\u73b0\u8c61<\/h2>\n<p>SpringBoot \u5e94\u7528\u5361\u6b7b\u3001\u65e0\u53cd\u5e94\u3002<\/p>\n<h2>\u5904\u7406\u8fc7\u7a0b<\/h2>\n<p>1\u3001 \u5bfc\u51fa\u7ebf\u7a0b\u6808\uff0c\u53d1\u73b0 Tomcat \u5904\u7406\u7ebf\u7a0b\u90fd\u963b\u585e\u5728\u83b7\u53d6\u8fde\u63a5\u4e0a\uff0c\u4ece\u6808\u4e0a\u770b\u8fde\u63a5\u6c60\u4f7f\u7528\u7684\u662f druid\u3002<\/p>\n<p>2\u3001 \u5bf9\u7167 druid \u6e90\u7801\uff0c\u53d1\u73b0\u7ebf\u7a0b\u4e00\u76f4\u88ab\u963b\u585e\u662f\u56e0\u4e3a\u6ca1\u6709\u8bbe\u7f6e\u83b7\u53d6\u8fde\u63a5\u7684\u8d85\u65f6\u65f6\u95f4\u3002\u800c\u4ece\u914d\u7f6e\u6765\u770b\u662f\u6709\u8bbe\u7f6e\u7684\u3002\u88ab\u963b\u585e\u7684\u7ebf\u7a0b\u6808\u5982\u4e0b\uff1a<\/p>\n<pre><code>\"http-nio-8006-exec-200\" #7057 daemon prio=5 os_prio=0 tid=0x00007fc82c0a3800 nid=0x1b99 waiting on condition [0x00007fc7c9a57000]\n   java.lang.Thread.State: WAITING (parking)\n    at sun.misc.Unsafe.park(Native Method)\n    - parking to wait for  &lt;0x00000000c2923bd8&gt; (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)\n    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)\n    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)\n    at com.alibaba.druid.pool.DruidDataSource.takeLast(DruidDataSource.java:1444)\n    at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1088)\n    at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:953)\n    at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4544)\n    at com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:661)\n    at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4540)\n    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:931)\n    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:923)\n    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:100)\n<\/code><\/pre>\n<p>3\u3001 \u901a\u8fc7\u5185\u5b58 dump \u53d1\u73b0\uff0cdruid \u8fde\u63a5\u6c60\u9664 \u8fde\u63a5\u4e32\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\u7b49\u51e0\u4e2a\u5c5e\u6027\u4e4b\u5916\u7684\u5c5e\u6027\u90fd\u662f\u9ed8\u8ba4\u503c\u3002<br \/>\n   \u6b64\u65f6\u8fde\u63a5\u6c60\u91cc\u603b\u5171\u67098\u4e2a\u8fde\u63a5\uff0c\u90fd\u662f\u7a7a\u95f2\u7684\uff0c\u5374\u6ca1\u6709\u7ebf\u7a0b\u80fd\u83b7\u53d6\u5230\u8fde\u63a5\uff0c\u90fd\u5728\u963b\u585e\u3001\u6ca1\u6709\u88ab\u5524\u9192\u3002\u7f51\u4e0a\u67e5\u4e86\u4e0b\uff0c\u5e94\u8be5\u662f druid \u7684bug\u3002<\/p>\n<p><!--more--><\/p>\n<p>4\u3001 \u518d\u67e5\u770b druid-spring-boot-starter \u6e90\u7801\uff0c\u53d1\u73b0\u4e0a\u9762\u51e0\u4e2a\u5c5e\u6027\u7684\u524d\u7f00\u662f <code>spring.datasource<\/code>\uff0c\u5176\u4ed6\u5c5e\u6027\u7684\u524d\u7f00\u662f <code>spring.datasource.druid<\/code> \u3002<\/p>\n<p><a href=\"https:\/\/github.com\/alibaba\/druid\/tree\/master\/druid-spring-boot-starter\">druid-spring-boot-starter \u5173\u4e8e\u914d\u7f6e\u7684\u4e3e\u4f8b<\/a><\/p>\n<pre><code>spring.datasource.url=\nspring.datasource.username=\nspring.datasource.password=\n\n# Druid \u6570\u636e\u6e90\u914d\u7f6e\uff0c\u7ee7\u627fspring.datasource.* \u914d\u7f6e\uff0c\u76f8\u540c\u5219\u8986\u76d6\nspring.datasource.druid.initial-size=5\nspring.datasource.druid.max-active=5\n<\/code><\/pre>\n<p>5\u3001 \u8fd9\u4e2a\u5e94\u7528\u7684\u53e6\u4e00\u4e2a\u95ee\u9898\u662f\uff0c\u4ed6\u4eec\u5bf9\u6bcf\u4e2a\u8bf7\u6c42\u8fdb\u884c\u62e6\u622a\u6821\u9a8c\u7b7e\u540d\uff0c\u7b7e\u540d\u7684\u79d8\u94a5\u4fe1\u606f\u662f\u5b58\u5728\u6570\u636e\u5e93\u91cc\uff0c\u5904\u7406\u8fc7\u7a0b\u4e3a\uff1a1. \u4ece\u6570\u636e\u5e93\u53d6\u79d8\u94a5\u4fe1\u606f\uff0c2. \u8fdb\u884c\u52a0\u89e3\u5bc6\u5e76\u6821\u9a8c\u3002\u5f00\u53d1\u4eba\u5458\u628a\u6574\u4e2a\u8fc7\u7a0b\u653e\u5728\u4e00\u4e2a\u53ea\u8bfb\u4e8b\u52a1\u91cc\u3002\u5176\u5b9e\u4ed6\u8fd9\u4e2a\u52a0\u89e3\u5bc6\u662f\u6bd4\u8f83\u8017\u65f6\u7684\uff0c\u7531\u4e8e\u6709\u4e8b\u52a1\uff0c\u6570\u636e\u5e93\u8fde\u63a5\u53ea\u80fd\u5728\u4e8b\u52a1\u7ed3\u675f\u65f6\u624d\u91ca\u653e\u3002\u8fd9\u5c31\u964d\u4f4e\u4e86\u8fde\u63a5\u4f7f\u7528\u6548\u7387\u3002<\/p>\n<p>\u672c\u4eba\u8d1f\u8d23\u7684\u9879\u76ee\uff0c\u7531\u4e8e\u4f7f\u7528\u4e86 Apollo\uff0c\u4e3a\u4e86\u9a8c\u8bc1\u5b9e\u65f6\u5237\u65b0\u914d\u7f6e\uff0c\u6709\u68c0\u67e5\u6bcf\u4e2a\u914d\u7f6e\u9879\u7684\u503c\u3001\u4e14\u91c7\u7528\u7684 HikariCP \uff0c\u672a\u8e29\u4e2d\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<hr \/>\n<p>\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u5fae\u4fe1\u516c\u4f17\u53f7: <strong>coderbee\u7b14\u8bb0<\/strong>\uff0c\u53ef\u4ee5\u66f4\u53ca\u65f6\u56de\u590d\u4f60\u7684\u8ba8\u8bba\u3002<br \/>\n<img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"258\" src=\"https:\/\/coderbee.net\/wp-content\/uploads\/2019\/01\/coderbee-note.jpg\" class=\"alignnone size-full wp-image-1707\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u4e00\u4e2a\u540c\u4e8b\u78b0\u5230\u7684\u6848\u4f8b\u3002 \u73b0\u8c61 SpringBoot \u5e94\u7528\u5361\u6b7b\u3001\u65e0\u53cd\u5e94\u3002 \u5904\u7406\u8fc7 &hellip; <a href=\"https:\/\/coderbee.net\/index.php\/framework\/20190309\/1794\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[255],"tags":[309,308],"_links":{"self":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1794"}],"collection":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/comments?post=1794"}],"version-history":[{"count":3,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1794\/revisions"}],"predecessor-version":[{"id":1799,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1794\/revisions\/1799"}],"wp:attachment":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/media?parent=1794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/categories?post=1794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/tags?post=1794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}