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项目启动时,如果没有配置数据库配置,启动时会抛出如下异常。

  1. Description:
  2.  
  3. Cannot determine embedded database driver class for database type NONE
  4.  
  5. Action:
  6.  
  7. If you want an embedded database please put a supported one on the classpath.
  8. If you have database settings to be loaded from a particular profile you may
  9. need to active it (no profiles are currently active).

2. 原因

springboot会自动注入数据源,而你却没有配,所以他就抛出该异常。

3. 如何不配

如果你只是简单的想建个项目,并不需要数据库支持,那么你可以让他不去注入数据源。

    1. // 一般你启动springboot项目,都会写一个有@SpringBootApplication注解的类
    2. // 你在这个注解中添加exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}
    3. // 即可无数据库运行
    4. // 如下
    5.  
    6. @SpringBootApplication(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})

最新文章

  1. 黑马程序员——C语言基础 枚举 宏定义 自定义 static exterm
  2. 【MySQL】drop大表
  3. php类型转换以及类型转换的判别
  4. Java Day 12
  5. LoadRunner--内存指标介绍
  6. session进程和服务
  7. JavaScript函数使用和DOM节点
  8. 如何使用.net开发一款小而美的O2O移动应用? ——“家庭小秘”APP介绍及采访记录
  9. redis消息队列,tp5.0,高并发,抢购
  10. JAVA 解决 SpringBoot 本地读取文件成功,打包后读取文件失败的方法
  11. 多条SQL语句对查询结果集的垂直合并,以及表设计时如何冗余字段
  12. linux用法总结
  13. Ubuntu下安装Goldendict(翻译软件)
  14. Linux内核源码分析之调度、内核线程模型 And Centos7.2's Kernel Resource Analysis
  15. HDU1285 确定比赛问题【拓扑排序+优先队列】
  16. Windows 下 Redis 服务无法启动,错误 1067 进程意外终止解决方案
  17. (F. MST Unification)最小生成树
  18. web开发经验
  19. nfs挂载出错:mount.nfs: access denied by server while mounting
  20. 树莓派GPIO控制RGB彩色LED灯

热门文章

  1. mona!mona!mona!
  2. python语句执行
  3. NIO之Buffer操作示例
  4. B/S选择文件夹上传
  5. [HG]奋斗赛G
  6. 设置Select下拉多选框功能,赋值与绑定问题
  7. nginx配置多个虚拟主机(mac)
  8. linux sed如何锁定某一行数据进行替换
  9. < 备考CET6 - 替换词 >
  10. SQL的一对多,多对一,一对一,多对多