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 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.的更多相关文章
- springboot启动报错Failed to configure a DataSource
2018-11-21 19:43:12.076 WARN 5392 --- [ main] ConfigServletWebServerApplicationContext : Exception e ...
- 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 创建 ...
- SpringBoot启动报错Failed to determine a suitable driver class
SpringBoot启动报错如下 Error starting ApplicationContext. To display the conditions report re-run your app ...
- 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 ...
- 新建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 ...
- 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 ************ ...
- 记一次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 ...
- 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 ...
- 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}),但是这样会排除 ...
随机推荐
- 消费者、生产者Java代码示例,wait
箱子中的苹果代表资源,现在有消费者从箱子中拿走苹果,生产者往箱子中放苹果.代码如下: 资源--箱子中的苹果: public class Box { int size; int num; public ...
- 重识 ArrayList
前言 ArrayList 作为 Java 集合框架中最常用的类,在一般情况下,用它存储集合数据最适合不过.知其然知其所以然,为了能更好地认识和使用 ArrayList,本文将从下面几方面深入理解 Ar ...
- 快速掌握SPSS数据分析
SPSS难吗?无非就是数据类型的区别后,就能理解应该用什么样的分析方法,对应着分析方法无非是找一些参考资料进行即可.甚至在线网页SPSS软件直接可以将数据分析结果指标人工智能地分析出来,这有多难呢 ...
- spring-cloud-kubernetes与k8s的configmap
本文是<spring-cloud-kubernetes实战系列>的第六篇,主要内容是在kubernetes上部署一个java web应用,该应用使用了spring-cloud-kubern ...
- Codeforces 889F Letters Removing(二分 + 线段树 || 树状数组)
Letters Removing 题意:给你一个长度为n的字符串,然后进行m次删除操作,每次删除区间[l,r]内的某个字符,删除后并且将字符串往前补位,求删除完之后的字符串. 题解:先开80个set ...
- 51nod 1020 逆序排列(dp,递推)
题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1020 题意:是中文题. 题解:很显然要设dp[i][j]表示 ...
- Map.Entry 接口
Map.Entry Map 接口下面的 Entry 接口. 该接口,定义一个键值对实体接口.Map.entrySet 方法返回的 Set 集合中的实体就是实现这个 它.只有一种方法可以获得 Map.E ...
- H5 的 sessionStorage和localStorage
1) H5 新增的 sessionStorage 和 localStorage 的区别 sessionStorage 和 java 的 session 差不多,可以短时间存储信息,电脑浏览器常用ses ...
- 【Offer】[7] 【重建二叉树】
题目描述 思路分析 Java代码 代码链接 题目描述 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树.假设输入的前序遍历和中序遍历的结果中都不含重复的数字.例如输入前序遍历序列{1,2,4, ...
- git之坑2
今天遇到的问题,git拉代码拉不了了,开发同事将他的家目录下的.ssh目录权限给改成777 造成pull push代码报错. 截图如下: 原因是哪个哥们把根目录的权限全部改为了777 解决方法,将他的 ...