spring boot启动报错Error starting ApplicationContext(未能配置数据源)
主要错误:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
未能配置数据源:未指定“url”属性,也无法配置嵌入式数据源。
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-03 09:47:45.300 ERROR 23160 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
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默认会加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration类,DataSourceAutoConfiguration类使用了@Configuration注解向spring注入了dataSource bean。因为工程中没有关于dataSource相关的配置信息,当spring创建dataSource bean因缺少相关的信息就会报错。
两种解决办法
1.在Application类上加
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
2.配置数据源:
例如在application配置文件中:
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://ip:端口号/数据库名称?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
spring boot启动报错Error starting ApplicationContext(未能配置数据源)的更多相关文章
- springboot启动报错,Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
报错: Error starting ApplicationContext. To display the conditions report re-run your application with ...
- spring Boot启动报错Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes
spring boot 启动报错如下 org.springframework.context.ApplicationContextException: Unable to start web serv ...
- 【原创】大叔经验分享(67)spring boot启动报错
spring boot 启动报错: Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback Logg ...
- Spring boot 启动报错 Failed to auto-configure a DataSource
1.Spring boot 启动报错 Failed to auto-configure a DataSource 参考资料https://blog.csdn.net/liuyinfei_java/ar ...
- 解决spring boot启动报错java.lang.NoClassDefFoundError: ch/qos/logback/classic/Level
解决spring boot启动报错java.lang.NoClassDefFoundError: ch/qos/logback/classic/Level 学习了:https://blog.csdn. ...
- Spring Boot 启动报错:LoggingFailureAnalysisReporter
17:57:19: Executing task 'bootRun'... Parallel execution with configuration on demand is an incubati ...
- spring boot 启动报错(spring-boot-devtools热部署后):The elements [spring.resources.cache-period] were left unbound. Update your application's configuration
详细错误代码: *************************** APPLICATION FAILED TO START *************************** Descript ...
- spring boot启动报错
Exception encountered during context initialization - cancelling refresh attempt: org.springframewor ...
- 新建Spring boot 启动报错 Failed to auto-configure a DataSource
今天学习springboot,使用idea创建项目.在选择组件时添加了mysq 然后在第一次启动的时候启动报错,错误信息如下: ***************************APPLICATI ...
随机推荐
- P3371 单源最短路径【模板】 洛谷
https://www.luogu.org/problem/show?pid=3371 题目描述 如题,给出一个有向图,请输出从某一点出发到所有点的最短路径长度. 输入输出格式 输入格式: 第一行包含 ...
- P2863 [USACO06JAN]牛的舞会The Cow Prom
洛谷——P2863 [USACO06JAN]牛的舞会The Cow Prom 题目描述 The N (2 <= N <= 10,000) cows are so excited: it's ...
- HashMap排序的问题
那么已知一个HashMap<Integer,User>集合, User有name(String)和 age(int)属性.请写一个方法实现对HashMap 的排序功能,该方法接收 Hash ...
- Java实验——输出一个数组里面连续子数组最大的和(二)文件操作
在本周的练习中,主要是对上周的实验进行健壮性的完善,即在所能考虑到的情况之中,尽量使自己的程序能够正常地运行. 在上周的实验中,我已经是在编程过程中考虑到用户输入的错误类型的问题,所以这一方面并没有多 ...
- Entity framework自定义字段实现思路
ublic class MyModel { public int MyModelID { get; set; } public string FixedProperty1 { get; set; } ...
- java大文件的分割和合并
原文:http://www.open-open.com/code/view/1441679313430 import java.io.File; import java.io.FileInputStr ...
- Django学习系列之request对象
先来一个简单的实例 urls.py from django.conf.urls import url from django.contrib import admin from cmdb import ...
- leetcode ----Trie/stack专题
一:Implement Trie (Prefix Tree) 题目: Implement a trie with insert, search, and startsWith methods. Not ...
- ubuntu下安装pycharm的方法
linux下安装pycharm是比较麻烦的. 安装pycharm之前要安装好JDK8,依次执行如下的命令: sudo add-apt-repository ppa:webupd8team/java s ...
- 【转载】HTTP POST GET SOAP本质区别详解
一 原理区别 一般在浏览器中输入网址访问资源都是通过GET方式:在FORM提交中,可以通过Method指定提交方式为GET或者POST,默认为GET提交 Http定义了与服务器交互的不同方法,最基本的 ...