package com.ydtech.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.ServletComponentScan; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.sql.DataSource; /** * Druid数据源配置 * * @author Yasepix * @date Oct 29, 2018 */ @Configuration //标识该类被纳入spring容器中实例化并管理 @ServletComponentScan //用于扫描所有的Servlet、filter、listener public class DruidConfig { @Bean @ConfigurationProperties(prefix="spring.datasource.druid") //加载时读取指定的配置信息,前缀为spring.datasource.druid public DataSource druidDataSource() { return new DruidDataSource(); } }