问题描述

***************************
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文件中<build></build>添加如下.来保证文件都能正常被扫描到并且加载成功.

<!-- 如果不添加此节点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 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embe的更多相关文章

  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. springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedde

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

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

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

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

  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. Failed to configure a DataSource: 'url' attribute is not specified and no embe...

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

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

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

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

  9. 新建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 ...

随机推荐

  1. BiggerInteger类

    java.math.BigInteger(需要导包)1.BigInteger构造方法*public BigInteger(String val)将 BigInteger 的十进制字符串表示形式转换为 ...

  2. c#项目减少源代码大小

    这次的代码缩减主要通过了这几个方面 1.bin和obj文件的删除(以前真的不知道,只是通过右键属性发现这些文件太大,然后上网搜索才知道,这些文件在源代码备份的时候是建议删掉的) 删掉的好处: 1.减少 ...

  3. JVM运行时数据区(一)

    1.名词解释: 栈帧:栈帧是用于支持虚拟机进行方法调用和方法执行的数据结构,它是虚拟机运行时数据区中的虚拟机栈的栈元素. 2.程序计数器: 程序计数器是一块比较小的内存空间,可以将它看作是当前线程所执 ...

  4. maven项目(多模块)

    在eclipse下构建maven项目,该项目由多个子模块组成. 1.创建一个父项目 NEW -->project-->maven-->maven Project,点击下一步,进入ne ...

  5. 吴恩达机器学习笔记45-使用支持向量机(Using A SVM)

    本篇我们讨论如何运行或者运用SVM. 在高斯核函数之外我们还有其他一些选择,如:多项式核函数(Polynomial Kernel)字符串核函数(String kernel)卡方核函数( chi-squ ...

  6. 免费开源的diff软件“meld”-替代beyond compare的神器

    命令行直接对比文件 meld dir1 dir2 & 1,安装 mld, 可以选择windows, linux, macos系统,都有提供安装. ubuntu 中安装: sudo apt-ge ...

  7. CSS box-sizing属性

    全文摘抄自 https://developer.mozilla.org/zh-CN/docs/Web/CSS/box-sizing 专门抄一遍是因为,我想当然的以为标准盒子模型设置的宽高是包括padd ...

  8. System.net.mail.smtpException;服务器提交了协议冲突 服务器响应为:

    最近发邮件遇到问题. 主机godaddy 端口 25,80 都可以用 stmp服务器地址:smtpout.secureserver.net 不支持ssl 我就吧 EnableSsl 设置为false了 ...

  9. (转)pycharm快捷键、常用设置、配置管理

    原文: http://blog.csdn.net/pipisorry/article/details/39909057 本博客一直在同步更新中! 内容包含:pycharm学习技巧 Learning t ...

  10. sessionStorage 基本使用

    sessionStorage 是浏览器数据存储的方法之一,用于临时保存同一窗口的数据,关闭窗口后sessionStorage 的数据将会不存在,它是以 key value 键值对的形式储存. 基本用法 ...