关于“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 classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
错误原因:
显然,根据错误原因可知找不到数据源配置。但是由于依赖方提供的API依赖中引用了一些多余的依赖触发了该自动化配置的加载,详情查看:https://blog.csdn.net/dyc87112/article/details/73739535,导致数据源配置自动启动生效。
这里是由于依赖了:
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.1</version>
</dependency>
解决方案:
1.不配置数据源的情况下:
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, MailSenderAutoConfiguration.class})
详细请参考:https://zhuanlan.zhihu.com/p/96508798
2.配置数据源:本文数据源配置在yml文件中:
spring:
datasource:
url: jdbc:mysql://xxxxxxxxxx
username: xxx
password: xxx
driver-class-name: com.mysql.jdbc.Driver
注意:pom文件中package类型不能为pom,否则项目编译后target中没有yml配置文件,同理打包后jar包中也没有yml配置文件。
如下位置:
<groupId>com.xxx</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<!--<package>pom</package>-->
<description>Demo project for Spring Boot</description>
以上!
关于“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 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 ...
- 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.Reason: Failed to determine a suitable driver class
解决方案: @SpringBootApplication(exclude = DataSourceAutoConfiguration.class) 作用://取消数据库配置 但是 在用到数据库的时候记 ...
- 5. Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
解决方案,见 https://www.jianshu.com/p/836d455663da
随机推荐
- K8S基础
四组基本概念 Pod/Pod控制器 Name/Namespace Label/Label选择器 Service/Ingress Pod Pod是k8s里能够被运行的最小的逻辑单元(原子单元) 1个Po ...
- 2016年 实验五 Internet与网络工具的使用
实验五 Internet与网络工具的使用 [实验目的] 本实验目的在于掌握 Telnet.FTP.Email的工作机理,并会在 Internet 上熟练使用相关工具软件. [实验条件] ⑴.个人计算机 ...
- 多Y轴图的尝试
最近的一篇文章中需要绘制多Y轴图形,Excel只能做双Y轴图,又尝试了Origin,SigmaPlot,Igor等软件,手动做起来相当繁琐,批量做更是觉得费劲,干脆尝试在MeteoInfoLab里实现 ...
- Exists 和Not Exists使用
描述:exists表示()内子查询语句返回结果不为空说明where条件成立就会执行主sql语句,如果为空就表示where条件不成立,sql语句就不会执行.not exists和exists相反,子查询 ...
- centos8安装及配置nfs4
一,用rpm检查是否有nfs-utils的包已安装 [root@localhost liuhongdi]# rpm -qa | grep nfs-utils nfs-utils-2.3.3-26.el ...
- ansible使用playbook的简单例子(ansible2.9.7)
一,ansible使用playbook的优点 1,用ansible执行一些简单的任务,使用ad-hoc命令就可以解决问题 如果执行复杂的功能,需要大量的操作,执行的ad-hoc命令会不够方便,这时我们 ...
- centos6.8 Mysql5.6.22 升级 mysql-5.7.20
一.检查系统环境 二.备份数据库 mysqldump –all-databases > allbackupfile.sql (建议:有条件的话可使用图形化界面备份,操作灵活) 三.下载安装文件 ...
- UI设计学习总结
UI设计学习总结 平面设计基础 平面构成 三大构成:点线面 重复构成 相同,有规律的重复 近似构成 形状,大小,色彩,肌理相似 渐变构成 色彩逐渐变化 发射构成 通过一点向四周扩散犹如绽放的花朵 密集 ...
- mysql自动化建表脚本
主脚本 配置文件 执行结果 主脚本内容 由于在awk中用常规方法无法转译单引号,所以用了单引号的八进制编码进行转译代替\047 等价于 ' [root@hadoop01 data]# cat crea ...
- Gerrit 服务搭建和升级详解(包括 H2 数据库迁移 MySQL 步骤)
1. 安装Gerrit-2.9.5版本(Ubuntu) Gerrit版本:Gerrit-2.9.5.war 操作系统:Ubuntu 16.04.3 JAVA环境:java version " ...