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 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).
报错原因
- 在网上找了解决方法,出现这个错误一般会是下面几种原因
- 原因一:Spring Boot的配置,DataSourceAutoConfiguration会自动加载数据源
- Spring boot 启动时会默认加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration这个类,DataSourceAutoConfiguration类使用了@Configuration注解向spring注入了dataSource bean。如果在项目配置文件中找不到数据源信息,项目在启动时就会报错
- 原因二:在application.properties/或者application.yml文件中没有添加数据库配置信息
- Spring Boot会自动加载classpath中配置文件中的数据源信息,如果找不到对应的数据源信息,就会报错
- 因为我搭建的是 服务的注册与发现(Eureka)项目,项目中不需要进行数据源配置,所以报错的是原因一:Spring Boot配置中的DataSourceAutoConfiguration自动加载数据源,却找不到数据源信息导致的
- 原因一:Spring Boot的配置,DataSourceAutoConfiguration会自动加载数据源
解决方法
- 在Spring Boot启动类加上注解@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class}),代表在启动时不需要项目自动加载数据源即可
@EnableEurekaServer
@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
public class EurekaApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
}
- Next
Spring Boot错误——SpringBoot 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.的更多相关文章
- SpringBoot 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embe
问题描述 *************************** APPLICATION FAILED TO START *************************** Description ...
- 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 ...
- 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 创建 ...
- 记一次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 ...
- 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 ************ ...
- 新建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 ...
- 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}),但是这样会排除 ...
- springboot项目启动报错 Failed to configure a DataSource: 'url' attribute is not specified and no embedde
参考:https://blog.csdn.net/Coyotess/article/details/80637837
- springboot启动报错Failed to configure a DataSource
2018-11-21 19:43:12.076 WARN 5392 --- [ main] ConfigServletWebServerApplicationContext : Exception e ...
随机推荐
- 前端插件--isCroll的使用
中文文档地址: http://wiki.jikexueyuan.com/project/iscroll-5/ 效果图: <!DOCTYPE html> <html lang=&quo ...
- H5C3--设置颜色的几种方式
设置颜色的方式: 关键字:red|blue 第一种:十六进制:#ffffff 第二种:rgb(红,绿,蓝): rgb(ffff00) rgba(红,绿,蓝,透明度) 第三种:hsl(色相,饱和度,明度 ...
- 读书笔记--Head First JavaScript 目录
1.交互式网络 2.存储数据 3.探索客户端 4.决策 5.循环 6.函数 7.表单与验证 8.驾驭网页 9.为数据带来生命 10.创建自定义对象 11.除错务尽 12.动态数据
- grpc入门2
rpc-gateway使用(同时提供rpc和http接口) 介绍第三方库 https://github.com/grpc-ecosystem/grpc-gateway 在grpc之上加一层代理并转发, ...
- grpc安装
整个过程就是: 1.客户端 发送 数据(以字节流的方式) 2.服务端接收,并解析. 根据 约定 知道要知道执行什么.然后把结果返回客户端 RPC就是 把 1.上述过程封装下,使其操作更加优化 2.使用 ...
- tesseract3.0.2font_id >= 0 && font_id < font_id_map_.SparseSize():Error:Assert failed:in file ..\..\classify\trainingsampleset.cpp, line 622
https://stackoverflow.com/questions/14025965/mftraining-gives-warning-no-protos-configs-for-f-in-cre ...
- java实体类的属性名首字母不能大写,不然el表达式无法取值
摘要:Java命名规范中,实体类属性名以小写字母开头,但并没有说不能以大写字母开头,然而事实告诉我,大写真不行 https://www.cnblogs.com/jnhs/p/10025757.html
- python基础--类的继承以及mro
继承: 什么是继承: 继承是一种关系,描述两个对象之间什么是什么的关系 在程序中,继承描述的是类和类之间的关系 例如 a继承了b,a就能直接使用b已经存在的方法和属性了 a称之为子类,b称之为父类,成 ...
- 2019.8.9 NOIP模拟测试15 反思总结
日常爆炸,考得一次比一次差XD 可能还是被身体拖慢了学习的进度吧,虽然按理来说没有影响.大家听的我也听过,大家学的我也没有缺勤多少次. 那么果然还是能力问题吗……? 虽然不愿意承认,但显然就是这样.对 ...
- Struts_添加客户练习
1.修改CustomerAction,实现ModelDriven接口 2.修改配置文件 3.修改表单提交地址