spring boot 启动遇到报错:Failed to configure a DataSource
spring boot 启动遇到报错,具体如下
Description:
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
Action:
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).
出错的原因:
在pom.xml中引入了 mybatis-spring-boot-starter,会自动加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration类
DataSourceAutoConfiguration类使用了@Configuration注解向spring注入了DataSource bean
因此如果没有配置DataSource,就会报错
解决的方法:
修改启动类,添加 @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}),阻止spring 自动注入DataSource
package com.abc.robin.backup; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
@SpringBootApplication
public class RobinBackupApplication { public static void main(String[] args) {
SpringApplication.run(RobinBackupApplication.class, args);
} }
spring boot 启动遇到报错:Failed to configure a DataSource的更多相关文章
- springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedde
springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedde 创建 ...
- 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 ...
- springboot启动报错Failed to configure a DataSource
2018-11-21 19:43:12.076 WARN 5392 --- [ main] ConfigServletWebServerApplicationContext : Exception e ...
- 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 ...
- SpringBoot 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embe
问题描述 *************************** APPLICATION FAILED TO START *************************** Description ...
- 记一次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 ...
- Spring Boot 2.1.7 启动项目失败,报错: "Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured."
一开始按照网上的很多解决办法是: 启动类头部声明@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class}),但是这样会排除 ...
- Spring Boot启动的报错 Stopping service [Tomcat]
我遇到的问题是项目中使用java_websocket的WebSocketClient,由于性能要求,需要再Controller直接继承WebSocketClient, 在项目启动过程中调试进入spri ...
- spring boot 启动数据库报错(Exception during pool initialization.)
2018-06-27 14:12:28.804 ERROR 14312 --- [ restartedMain] com.zaxxer.hikari.pool.HikariPool : HikariP ...
随机推荐
- SpringBoot 打包成war
1.修改pom.xml文件 <packaging>war</packaging> <properties> <project.build.sourceEnco ...
- 解决Web部署 svg/woff/woff2字体 404
1.打开服务器IIS管理器,找到MIME类型 2.添加类型 文件扩展名 MIME类型 .svg image/svg+xml.woff appli ...
- Vert.x(vertx) 认证和授权
每个线上系统几乎都是离不开认证和授权的,Vert.x提供了灵活.简单.便捷的认证和授权的支持.Vert.x抽象出了两个核心的认证和授权的接口,一个是 AuthProvider,另一个是User.通过这 ...
- Redis主从复制看这篇就够了
一.概念和作用 概念:主机数据更新后根据配置和策略, 自动同步到备机的master/slaver机制,Master以写为主,Slave以读为主. 作用: 读写分离: 容灾恢复: 二.复制原理 slav ...
- mac下搭建Apache服务器环境
mac下自带了一个Apache服务环境,所以不需要另外去下载,直接配置就好了. 一.启动Apache服务 在终端下输入 sudo apachectl start , 启动Apache服务.在浏览器输入 ...
- 攻防世界-web -高手进阶区-PHP2
题目 首先发现源码泄露 /index.phps 查看源代码 即: <?php if("admin"===$_GET[id]) { echo("<p>no ...
- Jpa的简介
Jpa:是用于数据持久化的一组标准接口. 1.HelloWorld的编写 创建EntityManagerFactory 创建EntityManager 开启事务 数据持久化 提交事务 关闭Entity ...
- Ingress-Nginx
注意: 本文只用的ingress-nginx版本为0.24.1,可在官方网站自行下载 https://github.com/kubernetes/ingress-nginx 一.Ingress-Ng ...
- Github清除历史提交,保留最新提交
有时候,需要启动一个新的分支,同时想摒弃历史信息,那么可以使用下面的方法来实现 #克隆git仓库 git clone [URL] #进入git仓库 cd [仓库名] #创建一个名为 new_branc ...
- Android APK开发 Drawable文件夹下的自定义Drawable文件
版本:2018/2/11 Drawable的分类 自定义Drawable SVG矢量图 个人总结的知识点外,部分知识点选自<Android开发艺术探索>-第六章 Drawable 1.Dr ...