Springboot reports error creating bean with name ‘datasource’ defined in class path resource, factory method ‘datasource’ three exception; nested exception is org.springframework.boot.autoconfigure.jdbc.Datasourceproperties $datasourcebeancreationexception: failed to determine a suitabledriver class solution
Problem background solution experience Lyric: cut me apart from two spirits
Problem background:
An error is reported when connecting to MySQL:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
... 87 more
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
Solution:
1. It can be seen from the error report that the configuration of datasource database cannot be found. After inspection, it was forgotten in application The YML configuration file configures the database information
spring:
datasource:
#url: jdbc:mysql://[ip]:[port]/[name]?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
url: jdbc:mysql://localhost:3306/mysqlTest?serverTimezone=UTC&characterEncoding=UTF-8
username: root
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
sql:
init:
encoding: utf-8
Read More:
- SpringBoot integrates Es error: Error creating bean with name ‘restHighLevelClient‘ defined in class path resource
- [Solved] Error creating bean with name ‘redisConnectionFactory‘ defined in class path resource…
- [Solved] seata:Error creating bean with name ‘globalTransactionScanner‘ defined in class path resource
- [Solved] Error creating bean with name ‘configurationPropertiesBeans‘ defined in class path resource…
- jasypt springboot Error: Error creating bean with name ‘enableEncryptablePropertySourcesPostProcessor’ defined in class path resource
- [Solved] Error creating bean with name ‘entityManagerFactory‘ defined in class path resource
- [Solved] Error creating bean with name ‘mappingJackson2HttpMessageConverter‘ defined in class path resource
- Error creating bean with name ‘servletEndpointRegistrar‘ defined in class path resource
- [Solved] springCloud Startup Error: Error creating bean with name ‘defaultValidator‘ defined in class path resource
- [Solved] Error creating bean with name ‘sqlSessionFactory‘ defined in class path resource
- [Solved] RabbitMQ Error: Error creating bean with name ‘rabbitConnectionFactory‘ defined in class path resource
- [Solved] springboot Error: Error creating bean with name ‘configurationPropertiesBeans‘ defined in class path
- [Solved] Error creating bean with name ‘configurationPropertiesBeans‘ defined in class path resource
- [Solved] spring boot Startup Error: Error creating bean with name ‘requestMappingHandlerMapping‘ defined in class path
- Springboot integration shiro error: UnsatisfiedDependencyException: Error creating bean with name ‘getShiroFilterFact
- [Solved] Error creating bean with name ‘fileVisitController‘ defined in file
- [Solved] Error creating bean with name ’emf’ defined in org.ngrinder.infra.config.DatabaseConf
- [Solved] Rabbitmq injection failed, bean creation failed, error creating bean with name ‘rabbitconnectionfactory’‘
- [Solved] Springboot Error: Error creating bean with name ‘xxxController‘
- springboot Integrate mybatis Error: Error creating bean with name ‘deptController‘: Unsatisfied dependency expresse