@Configuration
public class DruidConfiguration { @ConfigurationProperties(prefix = "spring.datasource")
@Bean
public DataSource druid() {
return new DruidDataSource();
}

在如下位置建立一个类,配置上面的内容


= =忘记说导入包了

        <dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.10</version>
</dependency>

导入这个包先

之后在applicaiton.properties下配置

spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.url=jdbc:mysql://localhost:3306/clouddb01?useUnicode=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&characterEncoding=UTF-8
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=123456sw

在启动的时候查看是否有druid数据源。

看 已经成功了!

springboot和Druid整合配置数据源的更多相关文章

  1. springboot2.0和Druid整合配置数据源

    1. idea使用spring 初始化工具初始化springboot项目(要选中web) 下一步,下一步 2. 在pom.xml中,引入Druid连接池依赖: <dependency> & ...

  2. 6_2.springboot2.x整合Druid和配置数据源监控

    简介 Druid首先是一个数据库连接池.Druid是目前最好的数据库连接池,在功能.性能.扩展性方面,都超过其他数据库连接池,包括DBCP.C3P0.BoneCP.Proxool.JBoss Data ...

  3. Springboot 实现前台动态配置数据源 (修改数据源之后自动重启)

    1.将 db.properties 存放在classpath路径; driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3 ...

  4. 五、springboot(二)配置数据源oracle

    1.添加依赖 <!-- jpa --> <dependency> <groupId>org.springframework.boot</groupId> ...

  5. SpringBoot学习之整合Druid的简单应用

    一.Druid介绍 Druid简介 Druid是目前Java语言中最好的数据库连接池之一.结合了 C3P0.DBCP 等 DB 池的优点,同时加入了日志监控.Druid 是一个分布式的.支持实时多维 ...

  6. springboot整合Druid(德鲁伊)配置多数据源数据库连接池

    pom.xml <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-ja ...

  7. 【springboot spring mybatis】看我怎么将springboot与spring整合mybatis与druid数据源

    目录 概述 1.mybatis 2.druid 壹:spring整合 2.jdbc.properties 3.mybatis-config.xml 二:java代码 1.mapper 2.servic ...

  8. SpringBoot系列之集成Druid配置数据源监控

    SpringBoot系列之集成Druid配置数据源监控 继上一篇博客SpringBoot系列之JDBC数据访问之后,本博客再介绍数据库连接池框架Druid的使用 实验环境准备: Maven Intel ...

  9. SpringBoot Druid整合,SpringBoot 集成Druid

    SpringBoot Druid整合,SpringBoot 集成Druid ================================ ©Copyright 蕃薯耀 2018年4月8日 http ...

随机推荐

  1. phpunit手动配置

    phpunit: #!D:\xampp\php\.\php.exe<?php/* PHPUnit * * Copyright (c) 2001-2013, Sebastian Bergmann ...

  2. C#中怎么解析JSON数据,并获取到其中的值?

    [1]首先我们根据创建一个json字符转 string json = @"[{'phantom':true,'id':'20130717001','data':{'MID':1019,'Na ...

  3. ACM学习历程—HDU4746 Mophues(莫比乌斯)

    Description As we know, any positive integer C ( C >= 2 ) can be written as the multiply of some ...

  4. shader学习推荐

    <DirectX 9.0 3D游戏开发编程基础> 当您理解了如何实现顶点着色器和像素着色器之后,接下来您可能想进一步了解使用这两种着色器能够实现哪些效果. 最好的方式就是研究一下现有的各种 ...

  5. Swift中数组和字典都是值类型

    在 Swift 中,所有的基本类型:整数(Integer).浮点数(floating-point).布尔值(Boolean).字符串(string).数组(array)和字典(dictionary), ...

  6. 非系统表空间损坏,rman备份恢复

    实验条件:有完整可用备份--查询表空间情况SQL> select tablespace_name,status from dba_tablespaces;TABLESPACE_NAME STAT ...

  7. CentOS 7关闭firewalld启用iptables

    在CentOS7中,有很多CentOS 6中的常用服务发生了变化. 其中iptables是其中比较大的一个.防火墙iptables被firewalld取代. 本文将介绍,如果采用systemctl关闭 ...

  8. 使用Azure CLI实现自动关闭Azure虚拟机的脚本

    Azure除提供Portal界面.PowerShell进行管理外,还提供Xplate的CLI对其进行管理. 在Azure的管理界面上可以下载各种平台的Xplate CLI的安装程序. 下面是一个小的脚 ...

  9. flume入门之一:flume 安装及测试

    http://flume.apache.org/ flume下载:http://mirror.bit.edu.cn/apache/flume/1.7.0/apache-flume-1.7.0-bin. ...

  10. js强加方法

    (function () { Array.prototype.removeItem=function (item) { var index=this.indexOf(item); if(index!= ...