IllegalArgumentException: At least one JPA metamodel must be present

前端 未结 4 1688
时光说笑
时光说笑 2020-12-01 15:53

while starting with spring rest I got following error as

org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'j

相关标签:
4条回答
  • 2020-12-01 16:26

    You can also disable Spring Data JPA's repository support by excluding the following auto configuration class (e.g. in your @EnableAutoConfiguration or @SpringBootApplication annotation)

    org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration
    

    For example:

    @EnableAutoConfiguration(exclude = JpaRepositoriesAutoConfiguration.class)
    
    0 讨论(0)
  • 2020-12-01 16:28

    You have added

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

    in your pom.xml.

    Spring boot will try automatically create an entity factory for JPA, but you do not have defined anything regarding JPA models.

    Try removing it in order to test what have you done so far.

    Afterwards you can check a tutorial using spring-data-starter-jpa like this guy

    0 讨论(0)
  • 2020-12-01 16:31

    I've fixed it by setting newer version of Hibernate.

    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
             <exclusions>
                 <exclusion>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-entitymanager</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.2.10.Final</version>
        </dependency>
    

    You can find a fully working example here: https://github.com/zobarov/ptc-task-executor

    0 讨论(0)
  • 2020-12-01 16:46

    This worked for me.

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
         <exclusions>
             <exclusion>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.10.Final</version>
    </dependency>
    
    0 讨论(0)
提交回复
热议问题