今天就跟大家聊聊有關(guān)SpringBoot中druid如何使用,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
十載的肅州網(wǎng)站建設(shè)經(jīng)驗(yàn),針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。營銷型網(wǎng)站建設(shè)的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整肅州建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)建站從事“肅州網(wǎng)站設(shè)計”,“肅州網(wǎng)站推廣”以來,每個客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
配置application.yml文件
spring:
datasource:
username: root password: 123456 driver-class-name: com.MySQL.jdbc.Driver url: jdbc:mysql://127.0.0.1:3306/test1?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true type: com.alibaba.druid.pool.DruidDataSource initialSize: 5 minIdle: 5 maxActive: 20 maxWait: 60000 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: SELECT 1 FROM DUAL testWhileIdle: true testOnBorrow: false testOnReturn: false poolPreparedStatements: true # 配置監(jiān)控統(tǒng)計攔截的filters,去掉后監(jiān)控界面sql無法統(tǒng)計,'wall'用于防火墻 filters: stat,wall,log4j maxPoolPreparedStatementPerConnectionSize: 20 useGlobalDataSourceStat: true connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500 initialization-mode: always @Configuration
public class myDruid {
@ConfigurationProperties(prefix = "spring.datasource") [@Bean](https://my.oschina.net/bean) public DataSource dataSource(){ return new DruidDataSource(); } //配置Druid監(jiān)控 [@Bean](https://my.oschina.net/bean) public ServletRegistrationBean statViewServlet(){ ServletRegistrationBean servletRegistrationBean= new ServletRegistrationBean(new StatViewServlet(),"/druid/*"); Mapmap =new HashMap<>(); map.put("loginUsername","admin"); map.put("loginPassword","admin"); servletRegistrationBean.setInitParameters(map); return servletRegistrationBean; } [@Bean](https://my.oschina.net/bean) public FilterRegistrationBean webStatFilter(){ FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(); filterRegistrationBean.setFilter(new WebStatFilter()); Map map = new HashMap<>(); map.put("exclusions","*.js,*.css,/druid/*"); filterRegistrationBean.setInitParameters(map); filterRegistrationBean.setUrlPatterns(Arrays.asList("/*")); return filterRegistrationBean; }
}
看完上述內(nèi)容,你們對SpringBoot中druid如何使用有進(jìn)一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。