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) 作用://取消数据库配置 但是 在用到数据库的时候记 ...
随机推荐
- 利用smtp发邮件
小功能,备忘 MailMessage objMailMessage = new MailMessage();//引入System.Net objMailMessage.From = new MailA ...
- window.open打开网址被拦截
window.open打开网址被拦截 标签: js 坑位 通过window.open打开一个网址,在火狐和IE系列浏览器下会拦截掉,除非用户主动点击允许才会成功,这样用户体验基本是恶心到产品的,而产品 ...
- windbg 调试 c++ std::exception
由于c++ std::exception在windbg里面调用堆栈显示不正确,可以通过加载了系统pdb和软件pdb后,!analyze -v可以分析出来,所有需要配置系统pdb. 1.把exe,pdb ...
- js 吸顶以及一些获取文档高度等小方法
1.返回html文档元素document.documentElement 2.文档的高度document.body.clientHeight 3.html文档可视高度==页面可见区域的高度docume ...
- R数据分析:潜在转化分析LTA的做法和解释(一)
之前给大家写了很多潜在类别分析的教程Mplus教程:如何做潜在类别分析LCA R数据分析:用R语言做潜类别分析LCA Mplus数据分析:潜在类别分析(LCA)流程(详细版) R数据分析:再写潜在类别 ...
- MAC清理
今日分享 Mac清理 有很多三方软件可以清理,以前用过腾讯的柠檬lite,每次就清个几百兆,系统数据感觉还是得自己手动清理才行 今天电脑又在提醒储存空间不足了,一看占用发现系统数据占了100多个G,学 ...
- mysql将公司数据随机挂在部门身上
1.创建示例数据 CREATE TABLE department_table ( company_code VARCHAR(10) COMMENT '公司编码', company_name VARCH ...
- Qt/C++音视频开发70-无感切换通道/无缝切换播放视频/多通道流畅切换/不同视频打开无缝切换
一.前言 之前就写过这个方案,当时做的是ffmpeg内核版本,由于ffmpeg内核解析都是代码实现,所以无缝切换非常完美,看不到丝毫的中间切换过程,看起来就像是在一个通道画面中.其实这种切换只能说是取 ...
- Spring Security默认登录页面代码位于哪里?
问:Spring Security默认登录页面代码位于哪里? 答:它是从此类生成的org.springframework.security.web.authentication.ui.DefaultL ...
- java EE进行Web开发时*.jsp页面的<%@显示“The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path”错误,webcontent文件夹总是出现红x或者java源码出现The import javax.servlet cannot be resolved 的解决方法
我们在用Eclipse进行Java web开发时,可能会出现这样的错误:The superclass javax.servlet.http.HttpServlet was not found on t ...