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 ...
随机推荐
- LA2238 Fixed Partition Memory Management
题目大意: m(m<=10)个内存区域,n(n<=50)个程序.找出一个方案来,使得平均结束时刻尽量小.题目保证有解. 同一个程序运行在不同大小的内存区域内,其运行时间不同.(注意,这里说 ...
- HDU6187 Destroy Walls
把这道题放了很久才来更新blog,似乎越来越懒了啊. 我们发现他给的城堡的坐标非常有趣啊,都是无理数. 对于其他所有点的坐标都是有理数的情况下,一个坐标为无理数的点绝对特别. 特别之处就是:经 ...
- centos安装消息队列beanstalkd
起因:开始想在windows安装beanstalkd,可以找了很多资料都没有成功.最终还是妥协.在虚拟机上装一个centos系统,然后在centos上安装beanstalkd供windows使用 yu ...
- mac ssh 远程容易断线解决方案
编辑文件 /etc/ssh/ssh_config 添加下面两行 ServerAliveInterval 60 ServerAliveCountMax 3 说明一下: #server每隔60秒发送一次请 ...
- JavaScript的原型链
首先介绍下原型~原型的作用:把方法放到原型中,就可以让同类型的对象共享 . 当我创建一个构造函数.构造函数里有原型.通过:构造函数名.prototype获取到当前构造函数的原型. function S ...
- [转]js的键盘事件
类型 键盘事件用来描述键盘行为,主要有keydown.keypress.keyup三个事件 keydown 当用户按下键盘上的任意键时触发,如果按住不放的话,会重复触发该事件 <div id=& ...
- JAVA--养成好的编程习惯
原文地址:http://user.qzone.qq.com/1159340782/2 略微牺牲一些性能,换来更好的可读性和可维护性是好的选择.以下不提倡和提倡的写法仅供参考. 代码中不提倡的写法 序号 ...
- web前端学习(二)html学习笔记部分(6)--fileAPI
1.2.18 html5 File API的应用 1.2.18.1 实现可选择列表 通过为列表项增加一个选择框,进而实现列表的多选和对选择文件的删除.同时,在选择.取消选择时实现操作栏的切换. 1. ...
- 媒体查询(media):设置PC端网页居中显示
@media screen and (min-width: 768px){ body{ background-color: #EAEAEA; } #fater{ width: 640px; margi ...
- WPF Popup实现拖动
问题一.popup总是置顶,遮挡其他窗口 最近发现popup设置打开后,总是会遮挡其他窗口,而我们只想让它仅仅在应用程序的上一层即可,并不像让它在最上面 解决方案是继承Popup重新定义控件Popup ...