Mybatis配置报错:Failed to configure a DataSource: 'url' attribute is not specified and no embe...
问题分析及解决方案
问题原因: 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>
Mybatis配置报错:Failed to configure a DataSource: 'url' attribute is not specified and no embe...的更多相关文章
- 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 embedde
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 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 ...
- 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使用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 ************ ...
- Failed to configure a DataSource: 'url' attribute is not specified and no embe...
问题分析及解决方案 问题原因: Mybatis没有找到合适的加载类,其实是大部分spring - datasource - url没有加载成功,分析原因如下所示. DataSourceAutoConf ...
- springboot启动报错Failed to configure a DataSource
2018-11-21 19:43:12.076 WARN 5392 --- [ main] ConfigServletWebServerApplicationContext : Exception e ...
- Spring boot&Mybatis 启动报错 Failed to auto-configure a DataSource
*************************** APPLICATION FAILED TO START *************************** Description: Fai ...
随机推荐
- XMind8破解,详细版(亲测)
废话不多说,直接上料: 一.资源 百度网盘XMind8: 链接:https://pan.baidu.com/s/1h2DXkni4-POEpHyBqLxjwA 提取码:kqgy 破解补丁: 链接:ht ...
- 常见的Native Crash类型,bug解决记录
APP调用Native的jar包接口出现闪退,仅仅settings应用,其他应用调用该包接口正常使用. 猜测1. jar包为64为,settings程序为32位,版本兼容性问题.(经验证,原因确实如此 ...
- uni-app 声音/震动提示,播放系统默认消息声音 安卓(Android)测试通过
可以跟据自己需求使用,有不足的地方希望大家帮忙补充 参数 type Options vibrate:震动 othre:铃声 1 msg_remind(type) 2 { 3 if(type=='vib ...
- WPF中获取主窗口 MainWindow 实例,以及在其他窗口中获取 MainWinodw 中的控件
var _mainWindow = Application.Current.Windows .Cast<Window>() .FirstOrDefault(window => win ...
- ES可视化平台kibana安装和使用
一.kibana介绍 Kibana是一个针对Elasticsearch的开源分析及可视化平台,用来搜索.查看交互存储在Elasticsearch索引中的数据. 二.kibana安装 1.解压 tar ...
- javascript【基础】数据类型
五种基本数据类型 Number String Boolean Undefined 一个没有设置值的变量 Null 表示一个空对象引用 ES6(Symbol) //ES6 一种复杂数据类型 Object ...
- cuda-gdb
1, cuda-gdb 可执行文件 2. b 打断点 3. 进入核函数 把断点打在核函数中 4. r 5. cuda block 1 thread 1 选取线程
- hutools密码算法库
hutool密码算法库 一.开发背景 Hutool针对Bouncy Castle做了简化包装,用于实现国密算法中的SM2.SM3.SM4. 国密算法工具封装包括: 非对称加密和签名:SM2 摘要签名算 ...
- 使用 Nginx 如何部署 web 项目
第一步:前往 Nginx 官方 下载 Nginx 资源包,建议下载 Stable version(长期稳定版本) 第二步:将 Nginx 压缩包解压到本地目录中(D:\Tools) 第三步:进入到 ...
- 理解函数调用_arguments对象作为函数参数的别名
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
