In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
The main content of this article is to explain "what is the method of springboot integrating druid and configuring dependency", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "what is the method of springboot integrating druid and configuring dependencies"?
Introduction to Druid
A large part of Java programs operate the database, and database connection pooling has to be used when operating the database to improve performance.
Druid is a database connection pool implementation on Alibaba's open source platform, which combines the advantages of DB pools such as C3P0 and DBCP, and adds log monitoring.
Druid can well monitor the execution of DB pooled connections and SQL, and is born for monitoring DB connection pooling.
Druid has deployed more than 600 applications in Alibaba and has passed the severe test of large-scale deployment in production environment for more than a year.
Spring Boot 2.0 and above use Hikari data sources by default. It can be said that both Hikari and Driud are the best data sources on Java Web. Let's focus on how Spring Boot integrates Druid data sources.
Druid official document: druid/druid-spring-boot-starter at master alibaba/druid (github.com)
Configuration dependency
Jdbc dependency, database dependency (mysql), druid dependency
Com.alibaba druid-spring-boot-starter 1.1.17 org.springframework.boot spring-boot-starter-jdbc mysql mysql-connector-java Basics-configuration Information
In application.yaml
Spring:# database datasource: url: jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&characterEncoding=utf-8 username: root password: root
Make a simple query, and the test results are shown in the figure:
Extend-configure druid monitoring featur
Under spring-datasource
Configure firewall, monitor page, and enable web monitoring
Spring:# Database datasource: url: jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&characterEncoding=utf-8 username: root password: root # druid configuration druid: # configuration Monitoring Firewall function filters: stat Wall # these two detailed parameters can be configured via filter-xxx filter: stat: enabled: true slow-sql-millis: 1000 # set 1000ms to slow query log-slow-sql: true # enable slow query monitoring wall: # here you can configure operations such as not allowing updates and deletions enabled: true # to open the monitoring page And configure the account password stat-view-servlet: enabled: true login-username: admin login-password: admin # reset-enable: false # reset button # to enable web monitoring. UrlPattern and exclusions have default values web-stat-filter: enabled: true # aop-patterns: cc.acdongla.boot.* configuration monitoring package
After starting the project, http://localhost:8080/druid/ can go to the monitoring page of druid
At this point, I believe you have a deeper understanding of "what is the method of springboot integrating druid and configuration dependence". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.