Starting Spring Boot Applications without Database Dependency
To ensure that Spring Boot applications can start successfully even in the absence of a database, certain configurations must be implemented.
Exception Encountered
When attempting to launch the application without an operational database, the following exception occurs:
org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
Cause
This error originates from Hibernate's reliance on database metadata to determine the appropriate dialect for executing SQL statements. Without a database connection, Hibernate cannot obtain this information.
Solution
To resolve this issue, the following configuration settings must be included in the application.yml file:
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
These settings configure the following:
Hibernate properties:
The above is the detailed content of How to Start Spring Boot Applications without Database Dependency?. For more information, please follow other related articles on the PHP Chinese website!