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项目后启动,报错为
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-09-26 09:54:41.640 ERROR 4392 --- [ 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).
问题分析及解决方案
问题原因: Mybatis没有找到合适的加载类,其实是大部分spring - datasource - url没有加载成功,分析原因如下所示.
- DataSourceAutoConfiguration会自动加载.
- 没有配置spring - datasource - url 属性.
- spring - datasource - url 配置的地址格式有问题.
- 配置 spring - datasource - url的文件没有加载.
方案一 (解决原因1)
排除此类的autoconfig。启动以后就可以正常运行。
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
方案二 (解决原因2)
在application.properties/或者application.yml文件中没有添加数据库配置信息.
spring:
datasource:
url: jdbc:mysql://localhost:3306/read_data?useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver
方案三(解决原因3)
spring.datasource.url = jdbc:mysql://192.168.0.20:1504/f_me?setUnicode=true&characterEncoding=utf8
方案四 (解决原因4)
yml或者properties文件没有被扫描到,需要在pom文件中添加如下.来保证文件都能正常被扫描到并且加载成功.
<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
以上方法,任选其一就行
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
参考:https://blog.csdn.net/Coyotess/article/details/80637837
- 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 ...
- 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 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embe
问题描述 *************************** APPLICATION FAILED TO START *************************** Description ...
- 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
2018-11-21 19:43:12.076 WARN 5392 --- [ main] ConfigServletWebServerApplicationContext : Exception e ...
- springboot项目启动报错 url' attribute is not specified and no embedded datasource could be configured
报错相关信息: 2019-07-22 17:12:48.971 ERROR 8312 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : **** ...
- 新建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项目刚刚创建就报异常,Failed to configure a DataSource: 'url' attribute is not specified and no embedded 的解决办法
错误信息: Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedde ...
随机推荐
- cnetos7--zabbix(3.4)-server安装
1.安装前准备 (1)关闭防火墙 [root@localhost ~]#Systemctl stop firewalld.service (2)开机关闭防火墙 [root@localhost ~]#S ...
- Linux下CFD-Post视图透明的解决方法
今天发生了一件很搞笑的事情,想用CFD-Post对计算结果做后处理,打开CFD-Post之后,背景居然是透明的,见图 做起后处理来完全看不清楚 下面是解决办法,很简单,步骤如下: 在终端中输入 sud ...
- FLUENT不同求解器离散格式选择【转载】
转载自:http://blog.163.com/wu_yangfeng/blog/static/16189737920104158950438/ 离散格式对求解器性能的影响 控制方程的扩散项一般采用中 ...
- C仿黑白棋版XO棋
两位玩家轮流在棋盘上放置不同颜色的棋子,一位玩家使用黑子,另一位使用白子,棋盘是一个偶数正方形. 只能将一个棋子放在对手的棋子旁边,使对手在水平.垂直.对角线方向上的棋子变成自己的棋子,游戏结束时,棋 ...
- uSurvival 1.41多人在线生存逃杀吃鸡类游戏源码
uSurvival - the new Multiplayer Survival Asset from the creator of uMMORPG. Features:* Kill Zombies ...
- IntelliJ IDEA悬停鼠标显示方法详细信息
1.如果View -> Toolbar勾选情况下, 直接点击按钮打开设置, 或是直接点击File -> Settings(或是快捷键)打开设置窗口. 2.搜索栏中输入Show quick ...
- SpringCloud-Eureka配置instanceId显示IP
eureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/ instance: preferIpAddress: tr ...
- Access 字段拼接(UPDATE 数据追加)
今天遇到一个需求,在Access数据库中,有个net_id 字段,它的值是由 “jjgrape” 这个字符串和 id 字段组成的,也就是说,要把 ‘jjgrape’ 和 id 字段拼接起来: 那怎么拼 ...
- 通过直方图进行PCA准备
import graphviz import mglearn from mpl_toolkits.mplot3d import Axes3D from sklearn.datasets import ...
- C# WinForm程序中使用Unity3D控件 (转)
https://www.cnblogs.com/cnxkey/articles/5394378.html 最近在自学Unity3D,打算使用这个时髦.流行.强大的游戏引擎开发一个三维业务展示系统,不过 ...