SpringBoot项目编译成功,启动报错

提示信息很明显,通过查看依赖关系,可以找到原因

导致这个问题的原因是因为,在 pom.xml 配置文件中,配置了数据连接技术 spring-boot-starter-jdbc 包 ,在启动配置文件时 ,Spring Boot 的自动装配机制就会去配置文件中找,相关的数据库的连接配置信息,如果找不到则抛出异常信息。

解决方法:

1. 在 SpringBoot 应用程序启动时,排除 jdbc 的自动装配机制

通过注解实现,启动类上添加如下

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class) 

2. 取消项目中spring-boot-starter-jdbc包的引入

适用于临时测试是否能够正常启动,且不需要数据库的情况。

3. 添加数据库配置

示例

spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://10.102.34.xx:3222/xxx_vvv?useUnicode=true&characterEncoding=utf-8
spring.datasource.username=xxxx
spring.datasource.password=xxxx@123
spring.datasource.druid.filters=config,stat
spring.datasource.druid.connectionProperties=config.decrypt=false;config.decrypt.key=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCJm+Ptt7DJ0ztn+Pw62ZTa1u1NSi6M+a/zp0LHzd6ybJx+f5CnszeYT0W/2VZVO+JPU+u2DRDxR9dxUGOanfLj0d47ssUgqZZlIxrrEsxMslnyVKkC0GGp8hgbCTAr+qBqdHZoLx2z4iXY5A/5YwdWqpkq3tLg8PVZT0W9IfzgzwIDAQAB
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.initialSize=2
spring.datasource.minIdle=1
spring.datasource.maxActive=20
# \u914d\u7f6e\u83b7\u53d6\u8fde\u63a5\u7b49\u5f85\u8d85\u65f6\u7684\u65f6\u95f4
spring.datasource.maxWait=60000

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.的更多相关文章

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

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

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

    解决方案,见  https://www.jianshu.com/p/836d455663da

随机推荐

  1. A. 【UNR #1】争夺圣杯

    题解: 一道比较水的题目 按照最一般的思路离散化后枚举最大值 然后考虑最大值的贡献 会发现需要分类讨论一下 发现对一段k的影响是等差数列 所以可以用线段树维护差分数组

  2. 大数据在教育中的应用 part2笔记

    什么是交叉检验(K-fold cross-validation)   K层交叉检验就是把原始的数据随机分成K个部分.在这K个部分中,选择一个作为测试数据,剩下的K-1个作为训练数据. 交叉检验的过程实 ...

  3. python全栈开发day37-html

    web准备总结: 结构标准:相当于人的身体.html就是用来制作网页的. 表现标准: 相当于人的衣服.css就是对网页进行美化的. 行为标准: 相当于人的动作.JS就是让网页动起来,具有生命力的 1. ...

  4. 【Java】 剑指offer(9) 斐波那契数列及青蛙跳台阶问题

     本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集   题目 写一个函数,输入n,求斐波那契(Fibonacci)数列的第n项 ...

  5. 051 日志案例分析(PV,UV),以及动态分区

    1.实现的流程 需求分析 时间:日,时段 分区表:两级 PV UV 数据清洗 2015-08-28 18:19:10 字段:id,url,guid,tracktime 数据分析 导出 2.新建源数据库 ...

  6. laravel 控制器使用MODEL

    第一步:引入MODEL类 use App\Http\Models\Sysdba; 第二步:使用 $uid = $request->input('uid'); 方法1. $model = new ...

  7. 浅谈html5 video 移动端填坑记

    这篇文章主要介绍了浅谈html5 video 移动端填坑记,小编觉得挺不错的,现在分享给大家,也给大家做个参考.一起跟随小编过来看看吧 本文介绍了html5 video 移动端填坑记,分享给大家,具体 ...

  8. 命令:hash

    简介 hash命令是bash的内置命令. 我们知道在bash中执行外部命令,会根据环境变量PATH来逐一搜索命令的路径. hash就是用于记住命令的路径,并且在下次执行命令的时候直接通过hash获取而 ...

  9. CF915E Physical Education Lessons 动态开点线段树

    题目链接 CF915E Physical Education Lessons 题解 动态开点线段树 代码 /* 动态开点线段树 */ #include<cstdio> #include&l ...

  10. 洛谷P1784 数独

    To 洛谷.1784 数独(类似(或者说相同)题:CODEVS.4966 简单数独(4*4数独) CODEVS.2924 数独挑战) 题目描述 数独是根据9×9盘面上的已知数字,推理出所有剩余空格的数 ...