You get an error when using Spring Data JDBC and AOT. For example, the following error happens when running ./gradlew processAot
Exception in thread "main" org.springframework.beans.factory.aot.AotProcessingException: Error executing 'org.springframework.beans.factory.aot.BeanRegistrationsAotProcessor': Error creating bean with name 'jdbcDialect' defined in class path resource [org/springframework/boot/data/jdbc/autoconfigure/DataJdbcRepositoriesAutoConfiguration$SpringBootJdbcConfiguration.class]: Unsatisfied dependency expressed through method 'jdbcDialect' parameter 0: Error creating bean with name 'namedParameterJdbcTemplate' defined in class path resource [org/springframework/boot/jdbc/autoconfigure/NamedParameterJdbcTemplateConfiguration.class]: Failed to initialize dependency 'liquibase' of NamedParameterJdbcOperations bean 'namedParameterJdbcTemplate': Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/liquibase/autoconfigure/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Failed to instantiate [liquibase.integration.spring.SpringLiquibase]: Factory method 'liquibase' threw exception with message: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/jdbc/autoconfigure/DataSourceConfiguration$Hikari.class]: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: Failed to determine a suitable driver class
When using Spring Data JDBC and AOT, you need to define a JdbcDialect bean. If using postgres for example, you can define the following bean to resolve the issue:
@Bean
JdbcPostgresDialect jdbcDialect() {
return JdbcPostgresDialect.INSTANCE;
}