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. fluent-动网格-动态层

    模型算例来源:http://blog.sina.com.cn/s/blog_599d8faa0100w4uj.html ​原视频下载地址:http://yunpan.cn/cujM2FxLuGdLK ...

  2. Java利用FastJson一行代码转List<Map>为List<Bean>

    /** * 字符串 -> json对象.实体对象.Map.List.List<Map> */ // 字符串 -> json对象 JSONObject json = JSON.p ...

  3. ubuntu进程监视器htop 清除黄色内存(缓存)

    大意是:对于CPU显示条: 蓝色为:低优先级的线程 绿色为:正常优先级线程 红色为:内核线程 对于内存显示条: 蓝色为:缓冲区(buffers) 绿色为:已使用的内存 (橘)黄色为:高速缓存(cach ...

  4. longitudinal models | 纵向研究 | mixed model

    A longitudinal study refers to an investigation where participant outcomes and possibly treatments o ...

  5. SpringBoot整合Quartz和H2的例子

    话不多说,直接上代码: pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xml ...

  6. #软件更新#Visual Studio更新到16.3.8

    #软件更新#Visual Studio更新到16.3.8 此次更新包括以下内容:(1)支持Xcode 11.2.(2)修复无法从System.String类型转化的bug.(3)修复UWP开发中,加载 ...

  7. flutter chip标签组件

    //一个Material widget. 它可以将一个复杂内容实体展现在一个小块中,如联系人.import 'package:flutter/material.dart'; class ChipDem ...

  8. Python3基础 函数 多值参数 元组与字典形式(键值对分别指出)

             Python : 3.7.3          OS : Ubuntu 18.04.2 LTS         IDE : pycharm-community-2019.1.3    ...

  9. java.io.EOFException at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer

    如题,网上找了相关资料查明是websocket连接超时的问题.使用了反向代理,因此超过60S没有数据传输的连接会断开. 把代理的那个超时时间设置长一点,无限长.你开什么玩笑!那还代理个啥玩意. 解决方 ...

  10. Spring cloud微服务安全实战-6-5jwt改造之日志及错误处理(1)

    在代码里,我们没有认证或者授权的filter.认证和授权的工作现在基本上完全由Spring Security的过滤器接管了. 本节就来看下 如何在Spring Security的过滤器链上加入我们自己 ...