Error creating bean with name 'dataSource' defined in class path resource

启动后会报这个错误,


Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: Invocation of init method failed; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
 

 

 

当然报这个错有很多原因,解释我碰到的两个

1. pom文件应用的包会存在重复,这个需要自己去检查,我是两个jpa的包报错的

2. 在运行是一定要选好dependencies,参看下图

Error creating bean with name 'dataSource' defined in class path resource