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. Python语言为什么被称为高级程序设计语言?

    Python是一种令人惊叹的编程语言,毫无疑问.从1991年的卑微开始,它现在几乎无处不在.无论您是在进行Web开发,系统管理,测试自动化,devop还是数据科学,Python在您的工作中发挥作用的可 ...

  2. Spring中都用到了哪些设计模式

    JDK 中用到了那些设计模式?Spring 中用到了那些设计模式?这两个问题,在面试中比较常见.我在网上搜索了一下关于 Spring 中设计模式的讲解几乎都是千篇一律,而且大部分都年代久远.所以,花了 ...

  3. 碎片记录——JMeter之 http post json对象与参数化调用,以及beanshell 引用Java源码

    参考文档 http://jmeter.apache.org/usermanual/component_reference.html#samplers https://blog.csdn.net/qq_ ...

  4. linux下将一系列.o文件打包成.a文件

    参考链接:https://www.cnblogs.com/joshtao/p/7380627.html

  5. MaxCompute按量计费计算任务消费监控告警

    MaxCompute 按量计费资源为弹性伸缩资源,对于计算任务,按任务需求提供所需资源,对资源使用无限制,同时MaxCompute按量计费的账单为天账单,即当天消费需要第二天才出账,因此,有必要对计算 ...

  6. C#在WinForm开发中Label换行方法

    很多朋友都会在开发WinForm中遇到Label要显示的内容太长,但却不能换行的问题.这里我总结了几种方法,供大家参考. 第一种是把Label的AutoSize属性设为False,手动修改Label的 ...

  7. 笨办法学Python(learn python the hard way)--练习程序21-30

    下面是练习21-30,基于python3 #ex21.py 1 def add(a, b): print("ADDING %d + %d" %(a, b)) return a+b ...

  8. windows server IIS启用Windows authentication

    双击打开IIS网站的authentication,如果有Windows authentication,直接右键启用即可,如果没有的话需要先安装一下Windows authentication,Micr ...

  9. HDU6424 Rikka with Time Complexity

    HDU6424 Rikka with Time Complexity 数学题~(真的数学题) #include <bits/stdc++.h> #define mp(_,__) make_ ...

  10. read_ila

    close all; clc; %clear; %点数 %point=40960; fft_point=200; show_point=200; end_point=1024; FS=30.72;%% ...