栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringBoot2之使用国产数据库连接池Druid遇到问题

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringBoot2之使用国产数据库连接池Druid遇到问题

SpringBoot2之使用国产数据库连接池Druid遇到问题
  • 前言
  • 一、遇到问题
  • 二、原因
  • 三、拓展

前言

在学习Spring Boot 2.x基础教程:使用国产数据库连接池Druid

SpringBoot2版本


        org.springframework.boot
        spring-boot-starter-parent
        2.6.7
         

一、遇到问题
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSource': Unsatisfied dependency expressed through field 'basicProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseType
Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType
二、原因

未引入这个依赖


            org.springframework.boot
            spring-boot-starter-jdbc
        
三、拓展

若SpringBoot2项目需要连接数据库mysql,使用数据库连接池druid则必须添加以下依赖


        
            mysql
            mysql-connector-java
        
        
        
            org.springframework.boot
            spring-boot-starter-jdbc
        
        
        
            com.alibaba
            druid-spring-boot-starter
            1.1.21
        

需要查看Druid监控则可以添加下面依赖


        
            org.springframework.boot
            spring-boot-starter-actuator
        

具体相关信息,都可以参考这边文章Spring Boot 2.x基础教程:使用国产数据库连接池Druid

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/856628.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号