Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could
问题分析及解决方案
问题原因: 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 xml配置文件中引用了数据库地址 所以需要对:等进行转义处理.但是在application.properties/或者application.yml文件并不需要转义,错误和正确方法写在下面了.
//错误示例
spring.datasource.url = jdbc:mysql\://192.168.0.20\:1504/f_me?setUnicode=true&characterEncoding=utf8
//正确示例
spring.datasource.url = jdbc:mysql://192.168.0.20:1504/f_me?setUnicode=true&characterEncoding=utf8
方案四 (解决原因4)
yml或者properties文件没有被扫描到,需要在pom文件中<build></build>添加如下.来保证文件都能正常被扫描到并且加载成功.
<!-- 如果不添加此节点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>
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could的更多相关文章
- 新建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 datasource could be configured.
新建了一个springboot项目报一下错误: Failed to configure a DataSource: 'url' attribute is not specified and no em ...
- 记一次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 ************ ...
- 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 ...
- 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 ...
- 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 spe ...
- Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
SpringBoot项目编译成功,启动报错 提示信息很明显,通过查看依赖关系,可以找到原因 导致这个问题的原因是因为,在 pom.xml 配置文件中,配置了数据连接技术 spring-boot-sta ...
- 关于“Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.”
Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the c ...
- 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
解决方案: @SpringBootApplication(exclude = DataSourceAutoConfiguration.class) 作用://取消数据库配置 但是 在用到数据库的时候记 ...
随机推荐
- Mac m1 安装 Homebrew
Homebrew 是 Mac 的包管理器,类似于 Linux 中的 apt,Windows 中的 choco. 自从 M1 芯片发布,Homebrew 正在积极适配新架构,如今已经有了原生支持 ARM ...
- 前端17号学习(html完结)
一.路径 1.目录文件夹和跟目录 实际工作中需要创建一个文件夹来管理他们. 目录文件夹,就是普通文件夹,里面存放页面相关素材,如html文件.图片等. 根目录,打开目录文件夹的第一层就是根目录. 2. ...
- AO SDK安装问题
ao sdk for .net安装时,需要进行验证.net框架,没装vs的时候会提示 arcobjects SDK for the Microsoft.NT Framework requires a ...
- 《前端运维》一、Linux基础--08Shell其他及补充
这一篇,我们来学习一些重要的命令,在工作中也会经常用到. 一.简单正则 要注意的是,有些命令不支持正则模式,比如fs.find等,有些是支持正则的,比如grep.awk.sed等.正则的语法和js中的 ...
- Git使用备忘录
定义 分布式版本控制工具 Git四个工作区域 工作区(Working Directory):就是你平时存放项目代码的地方 暂存区(Stage/Index):用于临时存放你的改动,事实上它只是一个文件, ...
- node 使用 pm2-logrotate 分割pm2日志 && 停止 pm2-logroatate
使用pm2-logrotate 解决pm2日志体积过大,进行分割 什么是pm2-logrotate? pm2-logrotate 是一个pm2的插件,可以对pm2日志进行管理,所以它的运行需要依靠pm ...
- Advanced .NET Remoting: 第 9 章 4.改变编程模型
Advanced .NET Remoting: 第 9 章 4.改变编程模型 前面的所有连接器在 .NET Remoting 应用程序的服务器端和客户端两方面增强功能.可插拔的连接器架构不仅支持创建连 ...
- 断言、drf之请求与响应
目录 一.断言 二.drf之请求 2.1 Request能够解析的前端传入的编码格式 2.2 Request类有哪些属性和方法(学过) 常用参数 Response类的实例化参数 三.drf之响应 3. ...
- mybatis-plus逻辑删除不生效的解决办法
我们在使用mybatis-plus时,一般设备逻辑删除是非常简单的,基本上在yaml等配置文件中做一下配置.然后在字段上注解@TableLogic就可以了.有不清楚的,可以参考https://www. ...
- Qt/C++离线地图的加载和交互/可以离线使用/百度和天地图离线/支持手机上运行
一.前言说明 在地图应用中,有很多时候是需要断网环境中离线使用的,一般会采用两种做法,一种是只下载好离线瓦片地图,然后根据不同的缩放和经纬度坐标绘制瓦片.这种方式优点是任何地图都支持,只需要拿到瓦片即 ...