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

解决:Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource

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

解决:Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource

解决:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.Reason: Failed to determine a suitable driver class
  • 一·问题描述:
    • (1)启动一个springboot程序,出现如下图异常:
  • 二·异常原因:
  • 三·解决办法:两种任选一种
    • 方式一:在boot项目的主程序@SpringBootApplication注解中,排除数据源自动配置类
    • 方式二:在应用的 /src/main/resources/application.yml 中添加连接数据库的基本配置信息

一·问题描述: (1)启动一个springboot程序,出现如下图异常:

二·异常原因:

Reason: Failed to determine a suitable driver class

原因:不能确定一个合适的驱动程序类

三·解决办法:两种任选一种 方式一:在boot项目的主程序@SpringBootApplication注解中,排除数据源自动配置类
#在主程序中添加如下代码:

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})

如图所示:

方式二:在应用的 /src/main/resources/application.yml 中添加连接数据库的基本配置信息
spring:
  #配置数据源
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://192.168.120.131:3306/gulimall_sms?useUnicode=true&characterEncoding=UTF-8&tinyInt1isBit=false&useSSL=TRUE&serverTimezone=Asia/Shanghai
    username: root
    password: 552200

如图所示:

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

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

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