简体   繁体   English

创建一个名为 'entityManagerFactory 的 bean

[英]Creating a bean with name 'entityManagerFactory

Hello as I see there is a lot of questions about this exception.你好,我看到有很多关于这个例外的问题。 I tried them all none of them worked.我尝试了所有这些都没有奏效。

I am working in Java 10 on a mac this is the error I get.我在 Mac 上使用 Java 10,这是我得到的错误。

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.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/HibernateJpaConfiguration.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/HibernateJpaConfiguration.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: org/hibernate/ejb/HibernatePersistence
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.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/HibernateJpaConfiguration.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: org/hibernate/ejb/HibernatePersistence
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.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: org/hibernate/ejb/HibernatePersistence
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/ejb/HibernatePersistence
Caused by: java.lang.NoClassDefFoundError: org/hibernate/ejb/HibernatePersistence
Caused by: java.lang.ClassNotFoundException: org.hibernate.ejb.HibernatePersistence

I don't really understand what is the meaning of this whole error message.我真的不明白这整个错误消息的含义是什么。

Here is my pom.xml这是我的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example.bootapp</groupId>
    <artifactId>bootapp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>bootapp</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.11</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

Just saying this is not my own code.只是说这不是我自己的代码。 This is code from my teacher in my java course.这是我的老师在我的 Java 课程中的代码。

I already tried everything what the other stackoverflow questions said.我已经尝试了其他 stackoverflow 问题所说的所有内容。 I already tried googling and duckduckgoing for this question.对于这个问题,我已经尝试过谷歌搜索和duckduckgoing。 i even tried asking my colleges in my course, but they don't have such a problem so I am thinking that it is a problem cause I am using macintosh.我什至尝试在我的课程中询问我的大学,但他们没有这样的问题,所以我认为这是一个问题,因为我使用的是 macintosh。 Everybody else is using windows and one dude is using linux.其他人都在使用windows,一个人在使用linux。 Here is the link for the github page of the project (not my code it is my teachers)这是项目的github页面的链接(不是我的代码,是我的老师)

This jar are missing in your classpath:您的类路径中缺少此 jar:

     org.hibernate.ejb.HibernatePersistence

Try to include this dependency :尝试包含此依赖项:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>5.3.7.Final</version>
</dependency>

Seems like the beans which is trying to be initialized is missing from the code you have.似乎您拥有的代码中缺少尝试初始化的 bean。 Also it is missing from your maven depedency.您的 maven depedency 中也缺少它。 Google the class you miss and find the correct maven dependency which is needed in order to run your project.谷歌你错过的课程,找到运行你的项目所需的正确 maven 依赖项。 Also tell that to your teacher because is a basic problem of the project.也告诉你的老师,因为这是项目的一个基本问题。

Here is a solution familiar to yours这是您熟悉解决方案

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 创建名为'entityManagerFactory的bean时出错 - Error creating bean with name 'entityManagerFactory 创建名称为&#39;entityManagerFactory&#39;的bean时出错 - error in creating bean with name 'entityManagerFactory' UnsatisfiedDependencyException:创建名为“entityManagerFactory”的 bean 时出错 - UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' 编译:创建名称为“ entityManagerFactory”的bean时出错 - Compilation: Error creating bean with name 'entityManagerFactory' 创建名称为&#39;entityManagerFactory&#39;的bean时出错-启动错误 - Error creating bean with name 'entityManagerFactory' - starting error 创建名称为&#39;entityManagerFactory&#39;,&#39;dataSource&#39;和&#39;delegatingApplicationListener&#39;的bean时出错 - Error creating bean with name 'entityManagerFactory' , 'dataSource' and 'delegatingApplicationListener' 错误:UnsatisfiedDependencyException:创建名为“entityManagerFactory”的 bean 时出错 - Error: UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' BeanCreationException:创建名称为&#39;entityManagerFactory&#39;的bean时出错 - BeanCreationException: Error creating bean with name 'entityManagerFactory' 创建名为&#39;entityManagerFactory&#39;的bean时出错 - Error creating bean with name 'entityManagerFactory' defined SpringBoot 测试 - 创建名为“entityManagerFactory”的 bean 时出错 - SpringBoot Test - Error creating bean with name 'entityManagerFactory'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM