EntityManagerFactory NoClassDefFoundError [英] entityManagerFactory NoClassDefFoundError

查看:123
本文介绍了EntityManagerFactory NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring Boot和嵌入式数据库来做简单的api,这让我很惊讶

I'm doing simple api with Spring Boot and embeeded database and it's hits me an

NoClassDefFoundError. :创建名称为bean的错误 'entityManagerFactory'

NoClassDefFoundError. : Error creating bean with name 'entityManagerFactory'

也许您知道我应该在pom.xml中包括哪个依赖项. Maven项目. 这是我所拥有的:

Maybe you know which dependency I should include to my pom.xml. Maven project. here is what i have:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.derby</groupId>
        <artifactId>derby</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

org.springframework.beans.factory.UnsatisfiedDependencyException: 创建类中定义的名称为'entityManagerFactory'的bean时出错 路径资源 [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: 通过方法'entityManagerFactory'表示的不满意的依赖关系 参数0;嵌套的例外是 org.springframework.beans.factory.UnsatisfiedDependencyException: 创建名称为'entityManagerFactoryBuilder'的Bean时出错 类路径资源 [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: 通过方法表达的不满意依赖性 'entityManagerFactoryBuilder'参数0;嵌套的例外是 org.springframework.beans.factory.BeanCreationException:错误 创建在类路径中定义的名称为"jpaVendorAdapter"的bean 资源 [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: 通过工厂方法实例化Bean失败;嵌套的例外是 org.springframework.beans.BeanInstantiationException:失败 实例化[org.springframework.orm.jpa.JpaVendorAdapter]:工厂 方法"jpaVendorAdapter"抛出异常;嵌套的例外是 java.lang.NoClassDefFoundError:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError:

推荐答案

hibernate-corehibernate-entitymanager通过spring-boot-starter-data-jpa

已编辑:您可以先尝试删除本地.m2/repository吗?有时它会损坏.

Edited: Could you first try removing you local .m2/repository? Sometime it gets corrupted.

rm -rf ~/.m2/repository

您能包括使用pom.xml内容的哪个Spring Boot版本吗?

Could you include which Spring Boot version are you using pom.xml content.

您还可以包括数据源和JPA属性吗?

Could you also include you data source and JPA properties?

这篇关于EntityManagerFactory NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆