SpringBoot will show error if there is no datasource configuration in application.yml/application.properties

221229 11:14:44906     main W bServerApplicationContext#591 Exception encountered during context initialization ... nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
...
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).

Because on start up SpringBoot will attempt to auto initialise a datasource, to run a spring boot application without datasource. You must disable the auto configuration for the datasource and may be for JPA also by adding exclude = {...} to the main entry.

Method #1

@SpringBootApplication
@EnableAutoConfiguration(exclude = {
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,
HibernateJpaAutoConfiguration.class})
public class Application { public static void main(String[] args) {
SpringApplication.run(PayPalApplication.class, args);
}
}

Method #2

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
public class AppBoot { public static void main(String[] args) {
SpringApplication.run(AppBoot.class, args);
}
}

未配置Datasource时, 启动 SpringBoot 程序报错的问题的更多相关文章

  1. 启动node程序报错:event.js:183 throw er; // unhandled 'error' event

    启动node程序时,报如下错误:

  2. 启动springboot项目报错Unable to start embedded Tomcat

    1.问题描述 最近在学习springcloud的时候,在父工程下新建一个model后,引入dashboard相关依赖后启动报错 2.产生原因 产生原因有可能就是pom.xml中下载的jar包版本冲突 ...

  3. idea启动springboot项目 报错:java.lang.NoSuchMethodError: javax.servlet.ServletContext.getClassLoader()Ljava/lang/ClassLoader;

    有一次启动springboot项目的时候,报了一个非常奇怪的错误,说是找不到servletContext,springboot不是自带tomcat的吗? 在网上找了好久,说是用以下方式解决. 解决方式 ...

  4. 解决方法:配置群集时# gem install redis 报错:Unable to require openssl, install OpenSSL and rebuild ruby

    问题:前面已经在/usr/local/src安装了ruby-2.3.0.tar.gz.rubygems-2.4.2.tar.gz.在配置 redis-3.1.1 群集中,使用gem install 安 ...

  5. 启动android程序报错

    提示错误如下: The connection to adb is down, and a severe error has occured. [2010-03-11 09:36:56 - HelloO ...

  6. C#编译器优化那点事 c# 如果一个对象的值为null,那么它调用扩展方法时为甚么不报错 webAPI 控制器(Controller)太多怎么办? .NET MVC项目设置包含Areas中的页面为默认启动页 (五)Net Core使用静态文件 学习ASP.NET Core Razor 编程系列八——并发处理

    C#编译器优化那点事   使用C#编写程序,给最终用户的程序,是需要使用release配置的,而release配置和debug配置,有一个关键区别,就是release的编译器优化默认是启用的.优化代码 ...

  7. xvfb启动PyQt4程序报Unable to load library icui18n错误

    xvfb启动PyQt4程序报如下错误: Unable to load library icui18n "Cannot load library icui18n: (libicui18n.so ...

  8. springboot 启动的时候报错 Error creating bean with name 'solrClient'

    springboot 启动的时候报错: org.springframework.beans.factory.BeanCreationException: Error creating bean wit ...

  9. SAP S4HANA 账户组的配置里'Int.Std.Grping'选项没勾选导致ABAP程序报错

    SAP S4HANA 账户组的配置里'Int.Std.Grping'选项没勾选导致ABAP程序报错 BP,试图创建一个新的vendor code, 角色是ZGM001, Grouping是G001, ...

  10. 使用root配置的hadoop并启动会出现报错

    1.使用root配置的hadoop并启动会出现报错 错误:         Starting namenodes on [master]         ERROR: Attempting to op ...

随机推荐

  1. pybind11

    fatal error: Python.h: no such file or directory 在使用pybind11时,如果不做调整可能就会出现这样的情况,Python.h一般出现在usr/inc ...

  2. [转帖]/etc/security/limits.conf 详解与配置

    https://www.cnblogs.com/operationhome/p/11966041.html 一. /etc/security/limits.conf 详解 /etc/security/ ...

  3. [转帖]sqluldr2 oracle直接导出数据为文本的小工具使用

    https://www.cnblogs.com/ocp-100/p/11098373.html 近期客户有需求,导出某些审计数据,供审计人进行核查,只能导出成文本或excel格式的进行查看,这里我们使 ...

  4. [转帖]ansible 安装 K8S

    作者:山河已无恙链接:https://www.zhihu.com/question/315497851/answer/2898814729来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业 ...

  5. 【转帖】Alpaca 7B:斯坦福从LLaMA-7B微调的语言模型

    https://www.jianshu.com/p/f8f8f660d2c3 https://crfm.stanford.edu/2023/03/13/alpaca.html https://crfm ...

  6. [转帖]BIS出口管制新规说明会,进一步明确十大问题

    https://zhuanlan.zhihu.com/p/573765504 10月13日晚9点,BIS就出口管制新规举行电话会议简报,出口执法助理副部长Thea Kendler主持会议.小白总结要点 ...

  7. [转帖]Linux中./configure、make、make install命令详解

    简单来说,make 是编译,make install 是安装.   总结:linux编译安装中configure.make和make install各自的作用  • ./configure是用来检测你 ...

  8. [转帖]egrep及扩展的正则表达式

    egrep: egrep = grep -E 语法:egrep [选项] PATTERN [FILE...] 扩展正则表达式的元字符: 字符匹配: .:匹配任意单个字符: [ ]:匹配指定范围内的任意 ...

  9. [转帖]总结:Springboot监控Actuator相关

    一.介绍 由于项目中使用的仍然是比较老旧的1.5.6版本,所以本文是基于此版本进行描述. 二.Actuator使用 ActuatorActuator是Spring Boot提供的对应用系统的监控和管理 ...

  10. Zabbix6.0的安装与IPMI的简单使用

    zabbix简介 1.zabbix的安装与使用 建议使用CentOS8进行部署, 不建议使用CentOS7, rpm包直接部署的话,CentOS8比较容易一些 支持mysql数据库.建议先期部署mys ...