最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Failed to determine a suitable driver class for MySQL using Spring Boot - Stack Overflow

programmeradmin1浏览0评论

Spring Boot application is running without any error from Eclipse, but after exporting the JAR file using Maven, I getting an error i.e.

Failed to determine a suitable driver class

pom.xml

<dependencies>      
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>        
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.27</version>
 </dependency>        
<dependency>
<groupId>.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
        
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
</dependencies>
<build>
<plugins>                   
<plugin>
<groupId>.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>                         
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>        
<archive>
<manifest>                                  <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addClasspath>true</addClasspath>
<mainClass>com.biswajit.RDSExample</mainClass>
</manifest> 
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

application.properties

spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
spring.datasource.url=jdbc:mysql://database-2.**..amazonaws:3306/mydb
spring.datasource.username=admin
spring.datasource.password=*****
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

How to resolve this issue? I get below exception:

Error creating bean with name 'dataSource' defined in class path resource [/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: Failed to determine a suitable driver class

发布评论

评论列表(0)

  1. 暂无评论