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})

spring boot 不连接数据库启动的更多相关文章

  1. 涨姿势:Spring Boot 2.x 启动全过程源码分析

    目录 SpringApplication 实例 run 方法运行过程 总结 上篇<Spring Boot 2.x 启动全过程源码分析(一)入口类剖析>我们分析了 Spring Boot 入 ...

  2. Spring Boot 2.x 启动全过程源码分析

    Spring Boot 2.x 启动全过程源码分析 SpringApplication 实例 run 方法运行过程 上面分析了 SpringApplication 实例对象构造方法初始化过程,下面继续 ...

  3. 【spring boot】spring cloud下spring boot微服务启动没有报错,但是访问访问不到

    spring cloud下spring boot微服务启动没有报错,但是访问访问不到 解决方法: 可能是端口被占用了,但是依旧启用成功了. 更改一下项目启用的端口号,再重新启动查看是否可以正常访问.

  4. Spring Boot项目指定启动后执行的操作

    Spring Boot项目指定启动后执行的操作: (1)实现CommandLineRunner 接口 (2)重写run方法 (3)声明执行顺序@Order(1),数值越小,优先级越高 (4)如果需要注 ...

  5. spring boot 是如何启动 tomcat

    Spring boot 的启动类启动后,tomcat 容器.Spring mvc .spring 事务等等第三方依赖也已经自动启动,那么spring boot 是如何启动的第三方依赖? 以spring ...

  6. Spring Boot 应用程序启动流程分析

    SpringBoot 有两个关键元素: @SpringBootApplicationSpringApplication 以及 run() 方法 SpringApplication 这个类应该算是 Sp ...

  7. spring boot中连接数据库报错500(mybatis)

    spring boot中连接数据库报错500(mybatis) pom.xml中的依赖 <!-- 集成mybatis--> <dependency> <groupId&g ...

  8. Spring Boot MyBatis 连接数据库

    最近比较忙,没来得及抽时间把MyBatis的集成发出来,其实mybatis官网在2015年11月底就已经发布了对SpringBoot集成的Release版本,Github上有代码:https://gi ...

  9. (转) Spring Boot MyBatis 连接数据库

    最近比较忙,没来得及抽时间把MyBatis的集成发出来,其实mybatis官网在2015年11月底就已经发布了对SpringBoot集成的Release版本,Github上有代码:https://gi ...

随机推荐

  1. jmeter性能工具 之 传参 (三)

    jmeter 主要有三种方式:键值对传参,json格式传参,外部传参 1.键值对传参 可以参考上篇登陆,使用的传参方式是键值对传参  2.json 格式传参 用json 格式传参不要忘了加http 头 ...

  2. selenium 自动化的坑(3)

    一天一坑系列(3) 今天不讲我是怎么定位了吧,今天讲的是关于弹窗的. 基于业务,一键全否之后需要二次确认,会弹出提示框,你会不会认为这是alert弹框?经过仔细查看元素,确认不是弹框,明明是div嘛, ...

  3. RMQ HelloWorld

    原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11791681.html Project Directory Maven Dependency < ...

  4. APP稳定性测试-monkey执行

    Monkey命令行可用的全部选项 *示例 : adb shell monkey -p cn.lejiayuan.alpha --pct-touch 30 --pct-motion 15 --pct-t ...

  5. Python3解leetcode Average of Levels in Binary Tree

    问题描述: Given a non-empty binary tree, return the average value of the nodes on each level in the form ...

  6. C++ Map相同key是否覆盖问题分析

    C++的标准库关联容器map是不允许有key相同的键值对存在的.那么当key已经存在的情况下,我们再次插入相同的key,那么key的value会被覆盖吗? 测试代码: 测试结果: 从测试结果我们可以得 ...

  7. CodeChef FNCS (分块+树状数组)

    题目:https://www.codechef.com/problems/FNCS 题解: 我们知道要求区间和的时候,我们用前缀和去优化.这里也是一样,我们要求第 l 个函数到第 r 个函数 [l, ...

  8. Uva 1471 Defense Lines(LIS变形)

    题意: 给你一个数组,让你删除一个连续的子序列,使得剩下的序列中有最长上升子序列, 求出这个长度. 题解: 预处理:先求一个last[i],以a[i]为开始的合法最长上升子序列的长度.再求一个pre[ ...

  9. 获取小程序accessToken

    private static String getAccessToken(){ String url = "https://api.weixin.qq.com/cgi-bin/token? ...

  10. Ajax对数据的删除与查看

    1.数据库找一张表: 颜色表2.主页面主页面的代码用到tbody:TBODY作用是:可以控制表格分行下载,从而提高下载速度.(网页的打开是先表格的的内容全部下载完毕后,才显示出来,分行下载可以先显示部 ...