java.lang.NoSuchMethodError: org.hibernate.cfg.Configuration.addAnnotatedClass

前端 未结 4 1155
余生分开走
余生分开走 2021-01-23 06:43

I am new to JPA & hibernate, when I try this tutorial . I added the following provider in my persistence.xml,

org.hibernate.ejb.HibernatePer         


        
相关标签:
4条回答
  • 2021-01-23 07:18

    Use the following dependencies...

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.3.6.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.6.4.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-annotations</artifactId>
        <version>3.5.5-Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.common</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>4.0.4.Final</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.7</version>
    </dependency>
    
    0 讨论(0)
  • 2021-01-23 07:25

    Check your version of Hibernate, you need hibernate-core 3.6.0 or higher to use the method addAnnotatedClass of org.hibernate.cfg.Configuration

    0 讨论(0)
  • 2021-01-23 07:27

    In addition:

    I've faced the same problem and I came to this page after googling for an answer and none of these answers helped me, so in case that somebody passes through the same problem:

    I had an ArrayList<Entity> and when I wanted to add an item to the arraylist, the NoSuchMethodException encountered. The problem was that the ArrayList had to be an Array.

    0 讨论(0)
  • 2021-01-23 07:37

    It look like the Hibernate Annotation jar is wrong. It is not compatible with the jar version. So that is why it showing the "java.lang.NoSuchMethodError"

    Could you please tell me the which jar version are you currently working , please specify the version ? Then only we have to easily address this.

    Which Hibernate version are you currently working ?

    Which Annotation version are you currently working ?

    please specify the version. Thanks.

    0 讨论(0)
提交回复
热议问题