When created a Spring Boot with JPA and Camel JPA, and throws below "Failed to instantiate [com.zaxxer.hikari.HikariDataSource] ... " error. If exclude the hikary depency for spring-boot-data-jpa start inside the pom.xml, this goes away. Finding difficulties in including a db connection with spring boot jpa and camel-jpa.
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.22.jar:5.3.22] at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.22.jar:5.3.22] ... 107 common frames omitted
CodePudding user response:
Assuming you're using mysql, the driver must be on the classpath. If you're using maven, that means your pom must declare the mysql driver as a dependency.
CodePudding user response:
It is missing mysql reference.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>