Starting Spring Boot without Database Dependency
Many applications use Spring Boot and Hibernate for data access, but may encounter errors when the database is unavailable during startup. To resolve this issue, follow these steps:
Adjust Connection Settings
In the application.yml file, modify the spring.datasource configuration:
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
Adjust Hibernate Settings
In the hibernate configuration within application.yml:
spring: ... 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
The above is the detailed content of How to Start Spring Boot Without Database Dependency?. For more information, please follow other related articles on the PHP Chinese website!