How to start spring-boot app without depending on Database?

Adding this alone worked for me:

spring.jpa.properties.hibernate.dialect: org.hibernate.dialect.Oracle10gDialect

Just replace the last part with your database dialect.


It was indeed a tough nut to crack.

After lot and lot of research and actually debugging the spring-boot, spring, hibernate, tomcat pool, etc to get it done.

I do think that it will save lot of time for people trying to achieve this type of requirement.

Below are the settings required to achieve the following requirement

  1. Spring boot apps will start fine even if DB is down or there is no DB.
  2. Apps will pick up the connections on the fly as DB comes up which means there is no need to restart the web server or redeploy the apps.
  3. There is no need to start the tomcat or redeploy the apps, if DB goes down from running state and comes up again.

application.yml :

spring:
  datasource:
    driverClassName: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/schema
    username: root
    password: root
    continueOnError: true
    initialize: false
    initialSize: 0
    timeBetweenEvictionRunsMillis: 5000
    minEvictableIdleTimeMillis: 5000
    minIdle: 0

  jpa:
    show-sql: true
    hibernate:
      ddl-auto: none
      naming_strategy: org.hibernate.cfg.DefaultNamingStrategy
    properties:
      hibernate:   
        dialect: org.hibernate.dialect.MySQL5Dialect
        hbm2ddl:
          auto: none
        temp:
          use_jdbc_metadata_defaults: false

I am answering here and will close the issue that you have cross-posted

Any "native" property of the JPA implementation (Hibernate) can be set using the spring.jpa.properties prefix as explained here

I haven't looked much further in the actual issue here but to answer this particular question, you can set that hibernate key as follows

spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults