Spring boot uses druid and monitoring configuration methods

The default data source of spring boot is: org apache. tomcat. jdbc. pool. DataSource

Druid is the best database connection pool in the Java language, and can provide powerful monitoring and extension functions.

The following describes how to configure and use Druid in spring boot

(1) Add Maven dependency (or jar package)\

2) . configure data source related information

(3) Configure monitoring statistics function

Configure Servlet

The following is the annotation based configuration in the springboot project, if it is web XML configuration, which can be configured according to rules.

DruidStatViewServlet:

Finally, add an annotation on the startup class: @ servletcomponentscan enables spring to scan servlets and filters written by ourselves.

Be careful not to forget the spring bootsampleapplication Add @ servletcomponentscan annotation on Java, otherwise it will be 404.

Then access after starting the project http://127.0.0.1:8080/druid/index.html You can view data sources and SQL statistics.

Start the application to access: http://127.0.0.1:8080/druid2/index.html Enter the account and password: admin2 / 123456.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>