zoukankan      html  css  js  c++  java
  • Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.

     

    从报错信息中,我们就可以分析出错误原因是触发了数据源的自动化配置,然而当前项目其实并不需要数据源。查其根源是依赖方提供的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
  • 相关阅读:
    cookie会话技术
    Vue实现任务列表效果
    Vue实现选项卡效果
    数组API(2)
    数组常用API(1)
    sticky,粘性定位
    了解HTTP协议和TCP协议
    快速排序
    冒泡排序
    【译】x86程序员手册21-6.3.5为操作系统保留的指令
  • 原文地址:https://www.cnblogs.com/cristin/p/8951919.html
Copyright © 2011-2022 走看看