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 ...
随机推荐
- oracle 索引操作
1 查询表中所有的索引 -- 固定写法"tb_user"(注意大小写)为表名 select * from user_indexes where table_name='tb_use ...
- (0416) python正则 RE 【用python处理sv源文件-格式化代码】
https://zhuanlan.zhihu.com/p/144069088
- (python)json 格式文件
Json 数据格式: python 的内置模块: json 格式数据声明只能有一层顶级层(字典格式,可以是任意对象,如字符串,列表等,但实际工作中一般为字典对象,) json 对象本质是一个字符串对象 ...
- Linux上的I2C基础知识
Linux上的I2C基础知识 什么是I2C I2C(Inter-Integrated Circuit,eye-squared-C),也称为 I2C 或 IIC,是一种同步.多控制器/多目标(主/从). ...
- 01 流程控制之for循环
'''1.什么是for循环 循环就是重复做某件事,for循环是python提供第二种循环机制2.为何要有for循环 理论上for循环能做的事情,while循环都可以做 之所以要有for循环,是因为fo ...
- CSS渐变样色的字
width: 118px; height: 17px; font-size: 13px; font-family: MicrosoftYaHei-Bold, MicrosoftYaHei; font- ...
- mysql问题汇总含解决方案
MySQL,插入数据提示"The table `xxx` is full" 背景:MEMORY引擎,hash索引 解决方法 1. 查看当前设置的table_size show va ...
- [CSP-S2019] Emiya 家今天的饭
洛咕 题意:原题面见链接,简单来说就是给出一个\(n*m\)的矩阵,每一行代表同一种烹饪方法,每一列代表同一种食材,\(a_{i,j}\)表示使用第i种烹饪方法第j种食材能做出多少种菜,要求至少做一道 ...
- https原理(五)双向实践(https代理)
本文为了证明: 1 双向可以通过直接转发tcp的中间人代理网关 2 双向可以防止明文中间人 开始.(服务端need,使用myhost.com-pub-capub.jks,myhost.com-pub- ...
- concat()函数
该函数可以将多个字符串连成一个字符串.使用语法concat(str1, str2, ...)返回结果参数拼接成的字符串,如果有任何一个参数为null,则返回值为null例子1.从person表查出数据 ...
