简体   繁体   English

当 Oracle 连接失败时如何保持 Spring 引导应用程序运行

[英]How to keep Spring boot application running when Oracle connection fails

I have an application written in Spring boot version 2.7.2 and connected to an Oracle database.我有一个用Spring boot version 2.7.2编写的应用程序,并连接到 Oracle 数据库。 How can my application still run even if it can't connect to the database (wrong url or dead database)即使无法连接到数据库,我的应用程序如何仍然运行(错误的 url 或死数据库)

  • configuration:配置:
spring:
  main:
    web-application-type: none
    log-startup-info: true
  profiles:
    active: production
  sql:
    init:
      continue-on-error: true
  datasource:
    url: jdbc:oracle:thin:@127.0.0.1:1521:thanbv
    username: thanbv

The application will not be able to run when my database has been shut down.当我的数据库关闭时,应用程序将无法运行。

 Failed to obtain JDBC Connection; nested exception is java.sql.SQLException
  • I tried adding this configuration but it still doesn't work:我尝试添加此配置,但仍然无法正常工作:
spring:
  sql:
    init:
      continue-on-error: true

How do I keep my application running regardless of whether the connection is successful with the database?无论与数据库的连接是否成功,如何让我的应用程序保持运行?

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})

it works for me这个对我有用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Spring Boot 应用程序中设置 oracle db 连接超时 - How to set oracle db connection timeout in spring Boot application 通过 websocket 连接保持 Spring 引导应用程序处于活动状态 - Keep Spring Boot application alive with websocket connection 具有MySQL连接和oracle连接的Spring Boot应用程序? (两个数据库) - Spring boot application with MySQL connection AND an oracle connection? (Two databases) 当 Hikari 给出连接超时时如何重新启动 spring 启动应用程序? - How to restart spring boot application when Hikari give connection timeout? 运行 Spring 启动应用程序时,我不断收到 Whitelabel 错误页面 - I keep getting a Whitelabel Error Page when running Spring Boot Application 运行Spring Boot应用程序时,Maven无法启动嵌入式Tomcat容器 - Maven fails to start embedded Tomcat container when running Spring Boot application 如何在 spring 引导应用程序中保持数据库活动 - How to keep database active in spring boot application 具有Oracle数据库重置连接的容器化Spring Boot应用程序 - Containerized spring boot application with oracle database resetting connection 运行我的 spring 引导应用程序时出现 UnsupportedDependencyException - UnsupportedDependencyException when running my spring boot application 如何保持 Spring Boot 服务在单个线程中运行并在应用程序之间共享 - How to keep a Spring Boot service running in a single thread and shared it across the application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM