您好,登錄后才能下訂單哦!
SpringBoot2中集成Druid配置是怎樣的,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
Maven<dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.1.13</version></dependency>12345配置application.properties# 設(shè)置項目的端口號server.port=9081#設(shè)置工程名字server.servlet.context-path=/mixmall# 數(shù)據(jù)庫的信息spring.datasource.type=com.alibaba.druid.pool.DruidDataSourcespring.datasource.url = jdbc:mysql://localhost:3306/java10?useSSL=false&serverTimezone=Asia/Shanghaispring.datasource.username = rootspring.datasource.password = Java20190713*yyspring.datasource.driverClassName = com.mysql.cj.jdbc.Driverspring.jpa.database = MYSQL# spring.jpa.show-sql = true 表示會在控制臺打印執(zhí)行的sql語句spring.jpa.show-sql = truespring.jpa.hibernate.ddl-auto = update# druid的配置spring.datasource.druid.initial-size=5spring.datasource.druid.max-active=20spring.datasource.druid.min-idle=5spring.datasource.druid.max-wait=60000spring.datasource.druid.validation-query=SELECT 1spring.datasource.druid.validation-query-timeout=2000spring.datasource.druid.time-between-eviction-runs-millis=60000spring.datasource.druid.min-evictable-idle-time-millis=300000#配置監(jiān)控統(tǒng)計攔截的filters,去掉后監(jiān)控界面sql無法統(tǒng)計,'wall'用于防火墻spring.datasource.druid.filters= stat,wall#######監(jiān)控配置# WebStatFilter配置,說明請參考Druid Wiki,配置_配置WebStatFilterspring.datasource.druid.web-stat-filter.enabled=truespring.datasource.druid.web-stat-filter.url-pattern=/*spring.datasource.druid.web-stat-filter.exclusions=/druid/*,*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.icospring.datasource.druid.web-stat-filter.session-stat-enable=truespring.datasource.druid.web-stat-filter.session-stat-max-count=10
spring.datasource.druid.web-stat-filter.principal-session-name=session_namespring.datasource.druid.web-stat-filter.principal-cookie-name=cookie_namespring.datasource.druid.web-stat-filter.profile-enable=# StatViewServlet配置,說明請參考Druid Wiki,配置_StatViewServlet配置默認falsespring.datasource.druid.stat-view-servlet.enabled=true# 配置DruidStatViewServletspring.datasource.druid.stat-view-servlet.url-pattern=/druid/*# 禁用HTML頁面上的“Reset All”功能spring.datasource.druid.stat-view-servlet.reset-enable=false#監(jiān)控頁面登錄的用戶名spring.datasource.druid.stat-view-servlet.login-username=admin#監(jiān)控頁面登錄的密碼spring.datasource.druid.stat-view-servlet.login-password=123456#IP白名單(沒有配置或者為空,則允許所有訪問)spring.datasource.druid.stat-view-servlet.allow=127.0.0.1,192.168.0.119#IP黑名單 (存在共同時,deny優(yōu)先于allow)spring.datasource.druid.stat-view-servlet.deny=#Spring監(jiān)控配置,說明請參考Druid Github Wiki,配置_Druid和Spring關(guān)聯(lián)監(jiān)控配置spring.datasource.druid.aop-patterns= com.zz.service.*
測試
http://localhost:9081/mixmall/druid/index.html
看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進一步的了解或閱讀更多相關(guān)文章,請關(guān)注億速云行業(yè)資訊頻道,感謝您對億速云的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。