spring  boot 启动遇到报错,具体如下

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

出错的原因:

  在pom.xml中引入了 mybatis-spring-boot-starter,会自动加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration类

  DataSourceAutoConfiguration类使用了@Configuration注解向spring注入了DataSource bean

  因此如果没有配置DataSource,就会报错

解决的方法:

  修改启动类,添加 @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}),阻止spring 自动注入DataSource

package com.abc.robin.backup;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
@SpringBootApplication
public class RobinBackupApplication { public static void main(String[] args) {
SpringApplication.run(RobinBackupApplication.class, args);
} }

spring boot 启动遇到报错:Failed to configure a DataSource的更多相关文章

  1. 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 创建 ...

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

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

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

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

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

  6. 记一次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 ...

  7. 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}),但是这样会排除 ...

  8. Spring Boot启动的报错 Stopping service [Tomcat]

    我遇到的问题是项目中使用java_websocket的WebSocketClient,由于性能要求,需要再Controller直接继承WebSocketClient, 在项目启动过程中调试进入spri ...

  9. spring boot 启动数据库报错(Exception during pool initialization.)

    2018-06-27 14:12:28.804 ERROR 14312 --- [ restartedMain] com.zaxxer.hikari.pool.HikariPool : HikariP ...

随机推荐

  1. 2019-11-29-win10-uwp-颜色转换

    原文:2019-11-29-win10-uwp-颜色转换 title author date CreateTime categories win10 uwp 颜色转换 lindexi 2019-11- ...

  2. NetCoreApi框架搭建三、AutoFac 依赖入注)

    这里不多做理论上的解释,因为我感觉自己也不是很完全的理解,所以只是记录我自己做的过程. 首先还是粘贴大神的链接:https://www.cnblogs.com/RayWang/p/11165509.h ...

  3. 02、JDBC查询

    ① 向数据库发送SQL查询语句 首先使用Statement声明一个SQL语句对象,然后让已创建的连接对象con调用方法createStatement()创建SQL语句对象. Statement sql ...

  4. 【spring】spring retry介绍

    一.为什么需要重试? 我们知道只要是网络请求都有失败的情况,这个时候增加retry机制是必要的.而spring全家桶中就有这么一套机制. 二.spring retry spring系列的spring ...

  5. Linux的权限管理操作-Linux从入门到精通第八天(非原创)

    文章大纲 一.网络相关概述二.网络相关命令三.项目上线流程(必须掌握)四.学习资料下载五.参考文章   一.网络相关概述 1. 网络发展 1.1 信息传递远古时期,人们就通过简单的语言.壁画等方式交 ...

  6. go安装配置

    https://www.cnblogs.com/wt645631686/p/8124626.html Win10下安装Go开发环境   关于Go语言有多么值得学习,这里就不做介绍了,既然看了这篇文章, ...

  7. 学Redis

    Redis 简介 Redis 是完全开源免费的,遵守 BSD 协议,是一个高性能的 key - value 数据库 Redis 与 其他 key - value 缓存产品有以下三个特点: Redis ...

  8. MySQL字符集、information_schema元数据(八)

    一.SQL字符集 它是一个系统支持的所有抽象字符的集合.字符是各种文字和符号的总称,包括各国家的文字.标点符号.图形符号.数字等 常用的字符集有:utf8.utf8mb4.utf8mb3(8.0),现 ...

  9. 用session实现的用户登陆,客户端是怎样获取到cookie信息的

    大家都知道cookie是存在客户端,session存在服务器端.那么客户端具体是怎样获取cookie信息的呢? 更好的阅读体验可访问 这里. 实验环境 实验环境:xampp + Thinkphp5 + ...

  10. C#进阶系列 ---- 《CLR via C#》

      [C#进阶系列]30 学习总结 [C#进阶系列]29 混合线程同步构造 [C#进阶系列]28 基元线程同步构造 [C#进阶系列]27 I/O限制的异步操作 [C#进阶系列]26 计算限制的异步操作 ...