新建了一个springboot项目报一下错误:

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

原因是加入了mybatis依赖而没有指定数据库url属性,解决方式:

1、去除mybatis依赖,即去除

<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>

2、加入数据库相关的配置,即加上

spring:
datasource:
url: jdbc:mysql://localhost:3306/db?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false
username: xxx
password: xxx

3、在启动类的@EnableAutoConfiguration或@SpringBootApplication中添加exclude = {DataSourceAutoConfiguration.class},排除此类的autoconfig。即

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class YourApplication { public static void main(String[] args) {
SpringApplication.run(YourApplication.class, args);
}
}

启动以后就可以正常运行。

springboot启动报错 Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.的更多相关文章

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

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

  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 determine a suitable driver class

    SpringBoot启动报错如下 Error starting ApplicationContext. To display the conditions report re-run your app ...

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

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

  6. SpringBoot使用mybatis,发生:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

    最近,配置项目,使用SpringBoot2.2.1,配置mybatis访问db,配好后,使用自定义的数据源.启动发生: APPLICATION FAILED TO START ************ ...

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

  8. 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 消费者提示需要配置数据源

    使用 由于给前端做分页 在启动消费者的时候遇到了这个问题 Failed to configure a DataSource: 'url' attribute is not specified and ...

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

随机推荐

  1. TensorFlow Distribution(分布式中的数据读取和训练)

    本文目的 在介绍estimator分布式的时候,官方文档由于版本更新导致与接口不一致.具体是:在estimator分布式当中,使用dataset作为数据输入,在1.12版本中,数据训练只是datase ...

  2. 用java实现取1-100之间的99个不重复的随机数 然后输出没有被取出的数字

    package cn.kgc.springtest2.demo1.dao; import java.util.BitSet; /** * @author * @create 2019-08-02 17 ...

  3. 怎样用QT在windows环境通过编程卸载installShield打包的程序

    通常情况下,如果是一个完备的软件,我们可以通过启动软件的uninstaller.exe之类的程序来完成卸载.但是使用installShield打包的程序,本身可能并不含有这类卸载程序.此时,我们可以通 ...

  4. 2019 Multi-University Training Contest 1

    2019 Multi-University Training Contest 1 A. Blank upsolved by F0_0H 题意 给序列染色,使得 \([l_i,r_i]\) 区间内恰出现 ...

  5. 树形动态规划 fjutoj-2392 聚会的快乐

    聚会的快乐 TimeLimit:1000MS  MemoryLimit:128MB 64-bit integer IO format:%lld Problem Description 你要组织一个由你 ...

  6. JOBDU 1108 堆栈的使用

    之所以把这道题目贴出来的原因,是因为真的有几个地方要注意的 题目1108:堆栈的使用 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:10763 解决:3119 题目描述: 堆栈是一种基本的 ...

  7. Event Loop js 事件循环初理解

    浏览器环境 执行栈 所有的 JS 代码在运行是都是在执行上下文中进行的.执行上下文是一个抽象的概念,JS 中有三种执行上下文: 全局执行上下文,默认的,在浏览器中是 window 对象 函数执行上下文 ...

  8. Java 中初始化 List 集合的 7 种方式

    1.常规方式 List<String> languages = new ArrayList<>(); languages.add("Java"); lang ...

  9. mybatis 生成代码配置 mybatis-generator:generate 的使用详解

    一.环境 mysql+eclipse 二.代码配置 pom.xml <?xml version="1.0" encoding="UTF-8"?> & ...

  10. Django2.* + Mysql5.7开发环境整合

    环境: MAC_OS 10.12 python 3.6 mysql 5.7.25 django 2.2.3 前提:python django mysql都已经安装成功可单独运行 一.settings中 ...