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. Java21 + SpringBoot3集成Spring Data JPA

    .markdown-body { line-height: 1.75; font-weight: 400; font-size: 16px; overflow-x: hidden; color: rg ...

  2. MySQL本地服务器与MySQL57网络服务器区别

    MySQL服务器与MySQL57服务器区别与不同处在哪里,他们各自的领域范围,能不能同时启动服务? 安装了MySQL-5.7.18.0版本数据库,版本中包含了MySQL Workbench可视化试图工 ...

  3. 【ARM】为堆和栈保留空的内存块

    此示例演示如何使用分散加载描述为堆栈和堆保留和清空内存块.它还显示链接器生成的相关符号. 在以下示例中,执行区域定义STACK 0x800000 EMPTY -0x10000定义了一个名为STACK ...

  4. DDP运行报错(单卡无错):ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1)

    使用DDP时出现错误,但是单卡跑无错误. 错误记录如下: RuntimeError: Expected to have finished reduction in the prior iteratio ...

  5. [转帖]JVM中年轻代里的对象什么情况下进入老年代?以及老年代垃圾回收算法-标记整理算法

    1.躲过15次GC之后进入老年代 系统刚启动时,创建的各种各样的对象,都是分配在年轻代里. 随着慢慢系统跑着跑着,年轻代满了,就会出发Minor GC ,可能1%的少量存活对像转移到空着的Surviv ...

  6. Grafana监控Oracle数据库的表大小等信息

    Grafana监控Oracle数据库的表大小等信息 方案 oracledb_exporter 以及 prometheus grafana 使用的SQL以及配置文件 [[metric]] context ...

  7. [转帖]tiup cluster scale-in

    https://docs.pingcap.com/zh/tidb/stable/tiup-component-cluster-scale-in tiup cluster scale-in 命令用于集群 ...

  8. [转帖]Jmeter笔记:使用Jmeter向kafka发送消息

    https://www.cnblogs.com/daydayup-lin/p/14124816.html 日常工作中有时候需要向kafka中发送消息来测试功能或者性能,这时候我们怎么办呢?我之前是自己 ...

  9. Python学习之十八_获取神通数据库所有的表数据量

    Python学习之十八_获取神通数据库所有的表数据量 背景 今天想获取一下所有数据库的表信息.但是发现神通数据库的系统表里面的表信息不正确 无法获取实际意义的表信息. 联系了下神通数据库的原厂高手. ...

  10. 银河麒麟系统信息获取V1.0版本

    银河麒麟系统信息获取 摘要 最近项目有一些兼容性测试需求. 可能需要获取一些系统配置信息便于相关的工作. 想着自己总结一下. 便于后续的不太熟悉的同事进行简要处理 银河麒麟获取版本 nkvers # ...