How to Start Spring-Boot App Without Database Dependency
Problem
Spring-boot applications dependent on a database may encounter issues starting when the database is down. This results in an exception related to the hibernate.temp.use_jdbc_metadata_defaults property. Setting this property in the application.yml file doesn't reflect at runtime.
Solution
To start a spring-boot application even without a database, configure the following settings in 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
Key Configuration:
With these configurations, the spring-boot application will start without the database, initialize the connection when the database becomes available, and seamlessly handle database outages without requiring a restart or redeployment.
The above is the detailed content of How to Start a Spring Boot App Without a Database: Overcoming the `hibernate.temp.use_jdbc_metadata_defaults` Issue?. For more information, please follow other related articles on the PHP Chinese website!