abbott_001 2021-12-23 15:21 采纳率: 42.9%
浏览 44
已结题

springboot+maven dynamic-datasource 动态切换数据源,启动报错

遇到问题
Description:

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

Action:

Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

  • 写回答

3条回答 默认 最新

  • abbott_001 2021-12-24 16:12
    关注

    已解决,
    解决方法:启动类@SpringBootApplication(exclude= {DruidDataSourceAutoConfigure.class}),注意是DruidDataSourceAutoConfigure,不是DataSourceAutoConfiguration.class

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • 燕_青 2021-12-23 15:57
    关注

    看错误信息应该是你的properties配置文件中没有配置数据源吧
    spring.datasource.dynamic.datasource.master.url

    评论
  • a1767028198 2021-12-23 21:15
    关注

    看你都发了无数次了,做一次好人吧,拿去自己改一下数据源的配置就行了
    链接: https://pan.baidu.com/s/1WeyLNisRLlbKVUwlXB4fSQ 提取码: rqq2 复制这段内容后打开百度网盘手机App,操作更方便哦

    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 1月12日
  • 已采纳回答 1月4日
  • 修改了问题 12月23日
  • 创建了问题 12月23日

悬赏问题

  • ¥20 springboot博客系统
  • ¥15 关于#c++#的问题:在A和B类中应该怎么定义复制构造函数来避开unordered_set复制构造的问题(相关搜索:头文件)
  • ¥15 MICE包多重插补后数据集汇总导出
  • ¥15 一道算法分析问题(关于3-MSAT)
  • ¥15 C++ FLUENT 化学反应速率 编写困难
  • ¥15 Python嵌套交叉验证
  • ¥15 linuxkit+elasticsearch
  • ¥15 兄得萌6.13do题😭😭大一小东西的work
  • ¥15 投不到原始数据,gdal投影代码
  • ¥20 卷积混响的代码帮写。。