springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedde

创建springboot项目后启动,报错为

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-09-26 09:54:41.640 ERROR 4392 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ***************************
APPLICATION FAILED TO START
*************************** 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).

问题分析及解决方案

问题原因: Mybatis没有找到合适的加载类,其实是大部分spring - datasource - url没有加载成功,分析原因如下所示.

  1. DataSourceAutoConfiguration会自动加载.
  2. 没有配置spring - datasource - url 属性.
  3. spring - datasource - url 配置的地址格式有问题.
  4. 配置 spring - datasource - url的文件没有加载.
方案一 (解决原因1)

排除此类的autoconfig。启动以后就可以正常运行。

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
方案二 (解决原因2)

在application.properties/或者application.yml文件中没有添加数据库配置信息.

spring:
datasource:
url: jdbc:mysql://localhost:3306/read_data?useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver
方案三(解决原因3)
spring.datasource.url = jdbc:mysql://192.168.0.20:1504/f_me?setUnicode=true&characterEncoding=utf8
方案四 (解决原因4)

yml或者properties文件没有被扫描到,需要在pom文件中添加如下.来保证文件都能正常被扫描到并且加载成功.

<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>

以上方法,任选其一就行

springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedde的更多相关文章

  1. springboot项目启动报错 Failed to configure a DataSource: 'url' attribute is not specified and no embedde

    参考:https://blog.csdn.net/Coyotess/article/details/80637837

  2. 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 ...

  3. 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 ...

  4. SpringBoot 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embe

    问题描述 *************************** APPLICATION FAILED TO START *************************** Description ...

  5. Spring Boot 2.1.7 启动项目失败,报错: "Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured."

    一开始按照网上的很多解决办法是: 启动类头部声明@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class}),但是这样会排除 ...

  6. springboot启动报错Failed to configure a DataSource

    2018-11-21 19:43:12.076 WARN 5392 --- [ main] ConfigServletWebServerApplicationContext : Exception e ...

  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项目启动出错 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 ...

  9. SpringBoot项目刚刚创建就报异常,Failed to configure a DataSource: 'url' attribute is not specified and no embedded 的解决办法

    错误信息: Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedde ...

随机推荐

  1. C# 使用大漠插件, 源码在Github和码云 ..希望对大家有所帮助

    c# 使用大漠插件. 完成 类似 按键精灵的 功能. 方法 注释 正在慢慢的 完善中 目录 仓库 github 码云 准备 效果图 如何运行 1. 注册 大漠dll 到com (资源在 源码 DLL ...

  2. Hadoop 压缩

    压缩的好处 文件压缩的好处:减少文件存储锁需要的磁盘空间,加速数据在网络和磁盘上的传输. 常见的压缩格式 压缩格式 工具 算法 文件扩展名 是否可以切分 DELATE 无 DEFLATE     .d ...

  3. OpenFOAM在原有算例上新建算例(只拷贝0,system,constant)

    原视频下载地址: https://yunpan.cn/cMpyBHSEvC7T4  (提取码:dca4)

  4. Javascript正则RegExp对象replace方法替换url参数值

    看别的博客有用eval执行正则表达式的写法, //替换指定传入参数的值,paramName为参数,replaceWith为新值 function replaceParamVal(paramName,r ...

  5. requests库详解

    import requests #实例引入 # response = requests.get('http://www.baidu.com') # print(type(response)) # pr ...

  6. ubuntu之路——day8.3 RMSprop

    RMSprop: 全称为root mean square prop,提及这个算法就不得不提及上篇博文中的momentum算法 首先来看看momentum动量梯度下降法的过程: 在RMSprop中: C ...

  7. 常忘知识点三-使用选择器继承来精简CSS --- @extend

    推荐一个很详细的sass教程:https://www.sass.hk/docs/ 在设计网页的时候常常遇到这种情况:一个元素使用的样式与另一个元素完全相同,但又添加了额外的样式.通常会在 HTML 中 ...

  8. git pull There is no tracking information for the current branch.

    在高版本的 git下面,也许会看见这样的提示: 解决方案:指定当前工作目录工作分支,跟远程的仓库,分支之间的链接关系. 比如我们设置master对应远程仓库的master分支 git branch - ...

  9. C++17 std::shared_mutex的替代方案boost::shared_mutex

    C++17 std::shared_mutex的替代方案boost::shared_mutex C++17boost  std::shared_mutex http://en.cppreference ...

  10. 先查询再插入,改为存储过程,java部分入参出参、mybatisxml【我】

    先查询再插入,改为存储过程 create or replace procedure PRO_REVENUE_SI(l_p_cd in Varchar2, l_c_cd in Varchar2, l_p ...