从报错信息中,我们就可以分析出错误原因是触发了数据源的自动化配置,然而当前项目其实并不需要数据源。查其根源是依赖方提供的API依赖中引用了一些多余的依赖触发了该自动化配置的加载。

如何解决

为了解决上面所述的问题,我们可以用两种方法来解决:

  • 通过外部依赖的修改来解决:通过与依赖方沟通,在对方提供的API依赖中去掉不必要的依赖
  • 通过禁用指定的自动化配置来避免加载不必要的自动化配置,下面列举了禁用的方法:

使用了@EnableAutoConfiguration的时候

  • 1  @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

使用了@SpringBootApplication的时候

  • 1  @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})

使用了@SpringCloudApplication的时候

  • 1. @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
  • 2. @SpringCloudApplication

通过配置文件来设置

    spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.的更多相关文章

  1. Spring Boot错误——SpringBoot 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

    背景 使用Spring Cloud搭建微服务,服务的注册与发现(Eureka)项目启动时报错,错误如下 *************************** APPLICATION FAILED T ...

  2. 记一次Spring boot集成mybatis错误修复过程 Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

    最近自己写了一份代码签入到github,然后拉下来运行报下面的错误 Error starting ApplicationContext. To display the conditions repor ...

  3. springboot启动报错 Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

    新建了一个springboot项目报一下错误: Failed to configure a DataSource: 'url' attribute is not specified and no em ...

  4. SpringBoot使用mybatis,发生:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

    最近,配置项目,使用SpringBoot2.2.1,配置mybatis访问db,配好后,使用自定义的数据源.启动发生: APPLICATION FAILED TO START ************ ...

  5. 新建springboot项目启动出错 Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

    错误信息入下: 2018-06-23 01:48:05.275 INFO 7104 --- [ main] o.apache.catalina.core.StandardService : Stopp ...

  6. 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 消费者提示需要配置数据源

    使用 由于给前端做分页 在启动消费者的时候遇到了这个问题 Failed to configure a DataSource: 'url' attribute is not specified and ...

  7. springboot项目启动报错 url' attribute is not specified and no embedded datasource could be configured

    报错相关信息: 2019-07-22 17:12:48.971 ERROR 8312 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : **** ...

  8. SpringBoot框架:'url' attribute is not specified and no embedded datasource could be configured问题处理

    一.问题如下: Description:    Failed to configure a DataSource: 'url' attribute is not specified and no em ...

  9. Configure swagger with spring boot

    If you haven’t starting working with spring boot yet, you will quickly find that it pulls out all th ...

随机推荐

  1. 剑指offer——python【第29题】最小的K个数

    题目描述 输入n个整数,找出其中最小的K个数.例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,. 思路 先排序后取数,排序可以用冒泡,插入,选择,快排,二分法等等, ...

  2. java学习(一)--- 基础语法

    学习内容来 自菜鸟教程 http://www.runoob.com/java/java-object-classes.html   Java基础 Java:一个Java程序可以认为是一系列的对象组合, ...

  3. Linux基础:用tcpdump抓包(转)

    https://segmentfault.com/a/1190000012593192 https://segmentfault.com/a/1190000009691705

  4. Luogu 1068 - 分数线划定 - [快速排序]

    题目链接:https://www.luogu.org/problemnew/show/P1068 题目描述世博会志愿者的选拔工作正在 A 市如火如荼的进行.为了选拔最合适的人才,A 市对所有报名的选手 ...

  5. [No0000152]C#基础之IL,轻松读懂IL

    先说说学IL有什么用,有人可能觉得这玩意平常写代码又用不上,学了有个卵用.到底有没有卵用呢,暂且也不说什么学了可以看看一些语法糖的实现,或对.net理解更深一点这些虚头巴脑的东西.其实IL本身逻辑很清 ...

  6. Codeforces Round div2 #541 题解

    codeforces Round #541 abstract: I构造题可能代码简单证明很难 II拓扑排序 III并查集 启发式排序,带链表 IV dp 处理字符串递推问题 V 数据结构巧用:于二叉树 ...

  7. for循环中break与continue的区别

    1.for循环 for循环是更加简洁的循环语句,大部分情况下,for循环可以代替while循环.do-while循环. for循环的格式为: for( 初始语句 ; 执行条件 ; 增量 ){循环体}执 ...

  8. Numpy float64和Python float是一样的

    >>> numpy.float64(5.9975).hex() # 函数用于将10进制整数转换成16进制,以字符串形式表示. '0x1.7fd70a3d70a3dp+2' >& ...

  9. JavaScript中各种对象之间的关系

    上图: 此外,补充一下图中用到的概念: 1.内置(Build-in)对象与原生(Naitve)对象的区别在于:前者总是在引擎初始化阶段就被创建好的对象,是后者的一个子集:而后者包括了一些在运行过程中动 ...

  10. Kafka笔记1(初步认识)

    Kafka 被称为“分布式提交日志”或“分布式流平台” 文件系统或数据库提交日志用来提供所有事务的持久记录,通过重放这些日志重建系统状态,同时Kafka数据是按照一定顺序持久化保存的,可以按需读取 K ...