package com.example.demo.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.servlet.Filter;
import javax.sql.DataSource;
import java.util.Arrays;
import java.util.HashMap;
/**
* 绑定druid相关数据源信息
*/
@Configuration
public class DruidConfig {
@ConfigurationProperties(
prefix = "spring.datasource"
)
@Bean
public DataSource druid(){
return new DruidDataSource();
}
/**
* 配置druid的监控
* 1配置一个druid的后台,管理servlet
* 2配置一个druid的filter
*
*/
访问阿里druid监控系统
最新推荐文章于 2024-07-22 10:56:57 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)