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. pojo层、dao层、service层、controller层的作用

    分层解耦介绍 1.pojo层(model) 实体层 数据库在项目中的类 model是模型的意思,与entity.domain.pojo类似,是存放实体的类. 类中定义了多个类属性,并与数据库表的字段保 ...

  2. 【css】 text-align 居中导航

    原理 :利用 inline-block 将 导航 作为 文本 , 被外层具有 text-align 属性的导航盒子包含 .从而实现居中效果 1.  html 结构 <header> < ...

  3. SQLServer解决deadlock问题的一个场景

    SQLServer解决deadlock问题的一个场景 背景 公司产品出现过很多次dead lock 跟研发讨论了很久, 都没有具体的解决思路 但是这边知道了一个SQLServer数据库上面计划100% ...

  4. [转帖]win10下使用Rclone将OneDrive映射到本地磁盘教程(开机自动挂载)

    win10下使用Rclone将OneDrive映射到本地磁盘教程(开机自动挂载) 下载rclone,winfsp和Git bash Rclone. Winfsp. 和 [Git bash](https ...

  5. [转帖]linux性能优化-CPU利用率

    参数说明 /proc/stat提供系统的CPU和任务统计信息. user(us): 用户态CPU时间,不包括下面的nice时间,但包括了guest时间. nice(ni): 代表低优先级用户态CPU时 ...

  6. [转帖]FT-2000+/64 - Phytium

      https://en.wikichip.org/wiki/phytium/feiteng/ft-2000%2B-64 Edit Values FT-2000+/64 General Info De ...

  7. 【技术剖析】7. 看看毕昇 JDK 团队是如何解决 JVM 中 CMS 的 Crash

    [技术剖析]7. 看看毕昇 JDK 团队是如何解决 JVM 中 CMS 的 Crashhttps://bbs.huaweicloud.com/forum/thread-168485-1-1.html ...

  8. git提交出现running pre-commit hook: lint-staged

    现象 今天提交代码的时候出现了 > running pre-commit hook: lint-staged Stashing changes... [started] Stashing cha ...

  9. 【发现一个问题】使用 fastcgo 导致额外的 `runtime._System` 调用的消耗

    作者:张富春(ahfuzhang),转载时请注明作者和引用链接,谢谢! cnblogs博客 zhihu Github 公众号:一本正经的瞎扯 为了避免 cgo 调用浪费太多资源,因此使用了 fastc ...

  10. linux虚拟机固定ip

    1.查看宿主机IP信息 在windows宿主机上,键盘输入win+r,输出cmd,打开终端命令行: 输入ipconfig /all,查看宿主机IP信息: 2.修改Linux虚拟机的配置文件 Linux ...