Ours is a Spring Boot 2.7.8 application with 2 different datasources. We would want the application to start and continue to run even if the datasources are down as it is not a hard stop.

Have tried the below, still application fails start

spring.sql.init.continue-on-error: true spring.sql.init.platform: oracle

Individual datasources are configured as below and initialized programmatically,

spring.datasource.db1.url: ... ... ...

spring.datasource.db2.url: ... ... ...

Comment From: wilkinsona

Without knowing what the failure is, it's very hard to help. Can you share the log output and stack trace of the failure?

Please note that spring.sql.init.continue-on-error only controls whether errors should be ignored while apply schema and data scripts to initialise the database. An example of such an error would be a schema script trying to create a table that already exists. The application will fail to start up when other errors related to accessing the database occur.

Comment From: syedyusufh

Sorry I should have included the error trace.

Have been using spring.datasource.db1.continue-on-error, however got a warning saying it is deprecated and asking to use spring.sql.init.continue-on-error. Also, we have the below properties set considering the non-availability of the datasource

spring.jpa.database: oracle spring.jpa.database-platform: org.hibernate.dialect.Oracle12cDialect spring.datasource.db1.driver-class-name: oracle.jdbc.OracleDriver spring.datasource.db1.hikari.minimum-idle: 0

Exception Stack:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.integration.IntegrationDataSourceScriptDatabaseInitializer]: Factory method 'integrationDataSourceInitializer' threw exception; nested exception is java.lang.IllegalStateException: Unable to detect database type
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
    ... 26 common frames omitted
Caused by: java.lang.IllegalStateException: Unable to detect database type
    at org.springframework.util.Assert.state(Assert.java:76)
    at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.determinePlatform(PlatformPlaceholderDatabaseDriverResolver.java:132)
    at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.lambda$resolveAll$0(PlatformPlaceholderDatabaseDriverResolver.java:96)
    at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.resolveAll(PlatformPlaceholderDatabaseDriverResolver.java:121)
    at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.resolveAll(PlatformPlaceholderDatabaseDriverResolver.java:96)
    at org.springframework.boot.autoconfigure.integration.IntegrationDataSourceScriptDatabaseInitializer.resolveSchemaLocations(IntegrationDataSourceScriptDatabaseInitializer.java:85)
    at org.springframework.boot.autoconfigure.integration.IntegrationDataSourceScriptDatabaseInitializer.getSettings(IntegrationDataSourceScriptDatabaseInitializer.java:73)
    at org.springframework.boot.autoconfigure.integration.IntegrationDataSourceScriptDatabaseInitializer.<init>(IntegrationDataSourceScriptDatabaseInitializer.java:47)
    at org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJdbcConfiguration.integrationDataSourceInitializer(IntegrationAutoConfiguration.java:244)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)

Comment From: wilkinsona

This is the expected behavior as the error has occurred before attempting to apply the scheme.sql scripts. It's failing when trying to determine the DB platform so that it knows which schema script to apply. You can avoid that by configuring the platform:

spring.integration.jdbc.platform=oracle

https://github.com/spring-projects/spring-boot/issues/4779 is tracking support for allowing an app to start when a DataSource is unable to connect to its database.