Java – Spring Boot 2 : How to configure HikariCP using application. Properties file

Spring Boot 2 : How to configure HikariCP using application. Properties file… here is a solution to the problem.

Spring Boot 2 : How to configure HikariCP using application. Properties file

I’m relatively new to Spring and Spring Boot,

but I can’t seem to find a guide on how to use Spring Boot, Flyway, and Spring Boot JPA to create applications that actually run on my machine. I always have the same problem :

Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$ FlywayConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required.

I

tried to fully configure HikariCP via the application.properties file, but I can’t seem to find a way. Any help is greatly appreciated.

My full stack trace and associated Java code and application.properties files are in this bullet point:

https://gist.github.com/anonymous/cb309a836ddae36f5e401697f763dde5

Solution

Remove the unwanted PersistenceConfiguration class. Spring Boot automatically configures the data source for you to use.

HikariCP is now the default pool implementation in Spring Boot 2.

Also removes all datasource-related properties from application.properties, except spring.datasource.url.

Related Problems and Solutions