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. Mysql在master上查看有哪些slave

    mysql> select * from information_schema.processlist as p where p.command = 'Binlog Dump'; 或 mysql ...

  2. Servlet的多线程和线程安全

    线程安全 首先说明一下对线程安全的讨论,哪种情况我们可以称作线程安全?网上对线程安全有很多描述,我比较喜欢<Java并发编程实战>给出的定义,“当多个线程访问某个类时,不管运行时环境采用何 ...

  3. 51Nod 算法马拉松28 C题 栈 单调队列

    欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - 51Nod1952 题意概括 有一个栈,有3种操作: Ο 从栈顶加入一个元素 Ο 从栈底加入一个元素 Ο 从栈 ...

  4. 在storm中运行jar产生模拟数据的时候,遇见的问题

    1.问题由来 命令:java -jar data.jar 1000 >>nginx.log 报错: Exception in thread "main" java.la ...

  5. PhotoShop 常用快捷键

    PhotoShop: ctrl+j 复制一块图层ctrl+t 自由变换钢笔画出来的是路径不是选区,将路径转化成选区:ctrl+回车 alt+delete 直排文字蒙版ctrl+d 取消选择中括号可改变 ...

  6. VS Code 配置 C/C++ 环境(转)

      写作原因 微软的 VSCode 一直以来为人诟病的一个问题就是对于 C/C++ 工程的编译以及调试支持度有限,配置起来比较复杂,但是 vscode-cpptools 团队经过一段时间的 bug 修 ...

  7. TensorFlow 核心——数据流图

    1 计算模型 -- 计算图(Graph) 更多参考:数据流图 TensorFlow 中的所有计算都会被转化为计算图上的节点.TensorFlow 是一个通过计算图的形式来表述计算的编程系统.Tenso ...

  8. @ConfigurationProperties和@Value 注入

    我这里使用的Spring Boot 2.0.1 版本 配置文件是 yml 格式文件 @ConfigurationProperties 在yml配置文件中: 在实体类中: 重点是实体类上的两个注解: @ ...

  9. 不一样的go语言-不同的OO

    前言   go语言因为产生时代的原因,大神们在设计go时,不得不考虑业界的流行趋势(编程理念),使得go既可以面向过程编程,也可以面向对象编程.这里不探讨两者的优劣,存在即是合理,面向过程编程经久不衰 ...

  10. 关于restful API url整理

    每个资源使用两个URL 资源集合用一个URL,具体某个资源用一个URL: /employees         #资源集合的URL /employees/56      #具体某个资源的URL 用名词 ...