问题分析及解决方案


问题原因: Mybatis没有找到合适的加载类,其实是大部分spring - datasource - url没有加载成功,分析原因如下所示.

  1. DataSourceAutoConfiguration会自动加载.

  2. 没有配置spring - datasource - url 属性.

  3. spring - datasource - url 配置的地址格式有问题.

  4. 配置 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的更多相关文章

  1. 新建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 ...

  2. 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 ...

  3. 记一次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 ...

  4. 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 ************ ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

    SpringBoot项目编译成功,启动报错 提示信息很明显,通过查看依赖关系,可以找到原因 导致这个问题的原因是因为,在 pom.xml 配置文件中,配置了数据连接技术 spring-boot-sta ...

  9. 关于“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 ...

  10. 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) 作用://取消数据库配置 但是 在用到数据库的时候记 ...

随机推荐

  1. three.js 性能优化之模型转化与压缩

    模型转换 obj转gltf 安装插件 npm i -g obj2gltf 执行转换命令 obj2gltf -i 11-6.obj -o 11-6.gltf -u 模型压缩 安装gltf-pipelin ...

  2. three.js优化

    Three js 开发的一些知识整理,方便后期遇到类似的问题,能够及时查阅使用. three.js 性能优化方面,整理一下常用的优化方法或者方向,供大家一个优化思考的方向 尽量重用Material和G ...

  3. ArkTs布局入门02——弹性布局(Flex)

    1.概述 弹性布局(Flex)提供更加有效的方式对容器中的子元素进行排列.对齐和分配剩余空间.容器默认存在主轴与交叉轴,子元素默认沿主轴排列,子元素在主轴方向的尺寸称为主轴尺寸,在交叉轴方向的尺寸称为 ...

  4. How to Disable SELinux in Ubuntu Server/Desktop

    https://www.configserverfirewall.com/ubuntu-linux/disable-selinux-ubuntu/ In this tutorial I will ex ...

  5. Spark内存调优

    一.概述Spark 作为一个基于内存的分布式计算引擎,其内存管理模块在整个系统中扮演着非常重要的角色.理解 Spark 内存管理的基本原理,有助于更好地开发 Spark 应用程序和进行性能调优.本文旨 ...

  6. 龙哥量化:缠论的笔、线段、中枢以及MACD背离分析实现

    声明:看到研究非常细致深入的文章,转载到我的博客园,以便学习和研究. (转载自聚宽的大象咖啡) 本文参考了如下相关文贴: [量化缠论]之分型.笔.线段识别1.1. 在该帖的基础上将线段和调整后的k线绘 ...

  7. DataTable 循环取值

    //list是datatable类型 for (int i = 0; i < list.Rows.Count; i++) { var A = list.Rows[i]["列名" ...

  8. UDP与TCP+JAVA相关理论

    相关知识 目录 相关知识 UDP UDP认识 UDP的特点(与TCP相比) UDP网络Socket编程(Java实现) 1.创建客户端 2.客户端图形界面 TCP Socket编程通信 JAVA 基础 ...

  9. Python 添加类型标注 | 散发着自由松散气息的代码

    Python 添加类型标注 | 散发着自由松散气息的代码 Python 如此简洁,书写者在声明变量时甚至无需考虑类型. 但是简洁与复杂间,是存在一个平衡点的.当我们书写较为复杂的项目时,还是希望可以拥 ...

  10. vue3-openlayers基础知识简介

    vue3-openlayers基础知识简介 OpenLayers 3 Primer openlayers6:入门基础(一) openlayers 入门教程 一.基础概念介绍 地图(Map) OpenL ...