java - 错误: Spring 启动数据库错误“org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration”

标签 java spring hibernate spring-mvc spring-boot

我正在使用Spring Boot,Hibernate和My sql,但出现错误。

org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“ org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration”的bean时出错:通过构造函数参数0表示的不满意依赖关系;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建在类路径资源[org / springframework / boot / autoconfigure / jdbc / DataSourceConfiguration $ Hikari.class]中定义的名称为'dataSource'的bean时出错:通过工厂方法实例化Bean失败;嵌套的异常是org.springframework.beans.BeanInstantiationException:无法实例化[com.zaxxer.hikari.HikariDataSource]:工厂方法'dataSource'引发了异常;嵌套的异常是java.lang.IllegalStateException:无法加载驱动程序类:com.mysql.jdbc.Driver
    在org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1267)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1124)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractBeanFactory.lambda $ doGetBean $ 0(AbstractBeanFactory.java:317)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:372)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1247)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractBeanFactory.lambda $ doGetBean $ 0(AbstractBeanFactory.java:317)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1089)〜[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:859)〜[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)〜[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)〜[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780)上[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)上[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    在org.springframework.boot.SpringApplication.run(SpringApplication.java:333)上[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    在org.springframework.boot.SpringApplication.run(SpringApplication.java:1277)上[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    在org.springframework.boot.SpringApplication.run(SpringApplication.java:1265)上[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    在com.trial.TrialApplication.main(TrialApplication.java:15)[classes /:na]
由以下原因引起:org.springframework.beans.factory.BeanCreationException:在类路径资源[org / springframework / boot / autoconfigure / jdbc / DataSourceConfiguration $ Hikari.class]中创建名称为“ dataSource”的bean时出错:通过工厂方法实例化Bean ;嵌套的异常是org.springframework.beans.BeanInstantiationException:无法实例化[com.zaxxer.hikari.HikariDataSource]:工厂方法'dataSource'引发了异常;嵌套的异常是java.lang.IllegalStateException:无法加载驱动程序类:com.mysql.jdbc.Driver
    在org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:590)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1247)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractBeanFactory.lambda $ doGetBean $ 0(AbstractBeanFactory.java:317)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1135)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    ...省略了28个通用框架
引起原因:org.springframework.beans.BeanInstantiationException:无法实例化[com.zaxxer.hikari.HikariDataSource]:工厂方法'dataSource'引发异常;嵌套的异常是java.lang.IllegalStateException:无法加载驱动程序类:com.mysql.jdbc.Driver
    在org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    ...省略了41个通用框架
引起原因:java.lang.IllegalStateException:无法加载驱动程序类:com.mysql.jdbc.Driver
    在org.springframework.util.Assert.state(Assert.java:94)〜[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    在org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:224)〜[spring-boot-autoconfigure-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    在org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:176)〜[spring-boot-autoconfigure-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    在org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:43)〜[spring-boot-autoconfigure-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    在org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration $ Hikari.dataSource(DataSourceConfiguration.java:83)〜[spring-boot-autoconfigure-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)〜[na:1.8.0_181]
    在sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)〜[na:1.8.0_181]
    在sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)〜[na:1.8.0_181]
    在java.lang.reflect.Method.invoke(未知来源)〜[na:1.8.0_181]
    在org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)〜[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    ...省略了42个通用框架

github存储库链接是
https://github.com/dishankgoyal/springsBoot

我怎样才能解决这个问题?

最佳答案

您的mysql jdbc jar似乎已损坏,因此无法加载驱动程序,建议您清除项目或删除.m2存储库可能会有所帮助。

如果maven项目更新无济于事,或者重新启动system/IDE也可能会有所帮助。

或者如果通过IDE添加了任何手动jar,则有时重新安装IDE也可能会有所帮助。

我建议所有这些,因为我在最后运行您的项目并可以正常工作。

关于java - 错误: Spring 启动数据库错误“org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52845269/

相关文章:

java - 如何在 Java 中将 ANSI 转换为 utf8?

java - Spring Stomp over Websocket : Stream large files

php - Google Drive 存储图像 - 好方法还是坏方法

java - 爬虫将 "mydomain#!article"转义为 "mydomain?_escaped_fragment_=article",如何找回原来的url?

java - 是否可以使用 Apache POI 解析 MS Word 并将其转换为 XML?

spring - jQuery mobile - 浏览器刷新页面后完全困惑

java - java spring config是否能够解析自定义变量解析器中的变量?

java - 从数据库中检索 java 对象列表而不是请求的对象列表

java - 使用 JPA/Hibernate/MySQL 测试 JTA XA 分布式事务

java - JVM 是否优化别名变量?