springboot 整合Druid
2021-04-09 10:28
标签:publickey spl ash lib 创建 use pack root zone 过程 1、导入包 2、配置application.yml文件 3、创建 config 文件夹 springboot 整合Druid 标签:publickey spl ash lib 创建 use pack root zone 原文地址:https://www.cnblogs.com/wt7018/p/13375116.htmldependency>
groupId>com.alibabagroupId>
artifactId>druidartifactId>
version>1.1.12version>
dependency>
spring:
datasource:
username: root
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/mybatisplus?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
# 配置数据源
type: com.alibaba.druid.pool.DruidDataSource
package com.wt.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
import java.util.HashMap;
@Configuration
public class MyDruidConfig {
@ConfigurationProperties("spring.datasource")
@Bean
public DataSource druidSource(){
return new DruidDataSource();
}
// 后台监控
@Bean
public ServletRegistrationBean statViewServlet(){
ServletRegistrationBean
public FilterRegistrationBean webFilter(){
FilterRegistrationBean
上一篇:Java格式化字符串Format
下一篇:二维数组
文章标题:springboot 整合Druid
文章链接:http://soscw.com/index.php/essay/73303.html