spring boot 不连接数据库启动
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).
用spring boot 搭建的项目,在配置文件不连接数据库启动项目会报错。
原因在于
spring boot默认会加载
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
类,DataSourceAutoConfiguration类使用了@Configuration注解向spring注入了dataSource
bean。因为工程中没有关于dataSource相关的配置信息,当spring创建dataSource bean因缺少相关的信息就会报错。
解决方法
在Application类上增加:
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
-------------------------------------------------------------------------------------------------------
SpringBoot项目取消数据库配置
1. 错误
springboot项目启动时,如果没有配置数据库配置,启动时会抛出如下异常。
- Description:
- Cannot determine embedded database driver class for database type NONE
- Action:
- If you want an embedded database please put a supported one on the classpath.
- If you have database settings to be loaded from a particular profile you may
- need to active it (no profiles are currently active).
2. 原因
springboot会自动注入数据源,而你却没有配,所以他就抛出该异常。
3. 如何不配
如果你只是简单的想建个项目,并不需要数据库支持,那么你可以让他不去注入数据源。
- // 一般你启动springboot项目,都会写一个有@SpringBootApplication注解的类
- // 你在这个注解中添加exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}
- // 即可无数据库运行
- // 如下
- @SpringBootApplication(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})
spring boot 不连接数据库启动的更多相关文章
- 涨姿势:Spring Boot 2.x 启动全过程源码分析
目录 SpringApplication 实例 run 方法运行过程 总结 上篇<Spring Boot 2.x 启动全过程源码分析(一)入口类剖析>我们分析了 Spring Boot 入 ...
- Spring Boot 2.x 启动全过程源码分析
Spring Boot 2.x 启动全过程源码分析 SpringApplication 实例 run 方法运行过程 上面分析了 SpringApplication 实例对象构造方法初始化过程,下面继续 ...
- 【spring boot】spring cloud下spring boot微服务启动没有报错,但是访问访问不到
spring cloud下spring boot微服务启动没有报错,但是访问访问不到 解决方法: 可能是端口被占用了,但是依旧启用成功了. 更改一下项目启用的端口号,再重新启动查看是否可以正常访问.
- Spring Boot项目指定启动后执行的操作
Spring Boot项目指定启动后执行的操作: (1)实现CommandLineRunner 接口 (2)重写run方法 (3)声明执行顺序@Order(1),数值越小,优先级越高 (4)如果需要注 ...
- spring boot 是如何启动 tomcat
Spring boot 的启动类启动后,tomcat 容器.Spring mvc .spring 事务等等第三方依赖也已经自动启动,那么spring boot 是如何启动的第三方依赖? 以spring ...
- Spring Boot 应用程序启动流程分析
SpringBoot 有两个关键元素: @SpringBootApplicationSpringApplication 以及 run() 方法 SpringApplication 这个类应该算是 Sp ...
- spring boot中连接数据库报错500(mybatis)
spring boot中连接数据库报错500(mybatis) pom.xml中的依赖 <!-- 集成mybatis--> <dependency> <groupId&g ...
- Spring Boot MyBatis 连接数据库
最近比较忙,没来得及抽时间把MyBatis的集成发出来,其实mybatis官网在2015年11月底就已经发布了对SpringBoot集成的Release版本,Github上有代码:https://gi ...
- (转) Spring Boot MyBatis 连接数据库
最近比较忙,没来得及抽时间把MyBatis的集成发出来,其实mybatis官网在2015年11月底就已经发布了对SpringBoot集成的Release版本,Github上有代码:https://gi ...
随机推荐
- 前端每日实战:30# 视频演示如何用纯 CSS 创作一个晃动的公告板
效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/wjZoGV 可交互视频教程 此视频 ...
- 三栏布局的三个典型方法(圣杯、双飞翼、flex)
聊聊三栏布局----左右定宽,中间自适应. 效果图: 圣杯布局 <!DOCTYPE html> <html> <head lang="en"> ...
- flask之视图函数从前端接收数据的方法
一:从前端接收查询字符串 query-string 注意:get和post都可以在url后面添加查询字符串?a=1&b=2 测试工具:postman 1:get方式接收 视图函数 from ...
- man uname
UNAME(1) User Commands/用户命令 UNAME(1) NAME/名称 uname - print system information/打 ...
- 【leetcode】1078. Occurrences After Bigram
题目如下: Given words first and second, consider occurrences in some text of the form "first second ...
- laravel后台账户登录验证(5.5.48版本)
首先我是菜鸟,对laravel框架也不是很熟悉,突然有一天心血来潮就想研究一下laravel的后台登录用户登录的流程, 虽然公司项目中有这样的一套流程,也看了好几遍,越看越简单,越看我就越会了,当自己 ...
- 吸$DN
旧博客:https://blog.csdn.net/gmh77 从几年前开始用CSDN,见证了CSDN是如何一步步走向辣鸡的 广告?ABP 登录看文章?雨我无瓜账号常年不退 分类要慢慢点也可以接受 前 ...
- 20180821-Java封装
java 封装 在面向对象程式设计方法中,封装(英语:Encapsulation)是指,一种将抽象性函式接口的实作细节部份包装.隐藏起来的方法. 封装可以被认为是一个保护屏障,防止该类的代码和数据被外 ...
- 学习日记3、投机取巧使两个表的数据同时在一个treeGrid中显示
不多说了直接上代码, $('#List').treegrid({ url: '@Url.Action("GetList")', width: $(window).width() - ...
- loj#2838 「JOISC 2018 Day 3」比太郎的聚会
分析 预处理每个点的前根号小的距离 对于每次询问删除点小于根号则已经处理好 否则直接暴力dp即可 代码 #include<bits/stdc++.h> using namespace st ...