hibernate4注解报错

当使用hibernate3.5以上版本时,会用到hibernate-jpa-2.0-api-1.0.1.Final.jar这个JAR包,而其中的某些类与JAVAEE中类存在冲突,类名一样,包名一样,这样就找不着到底是哪个类了。

我这里映射文件的时候出错了:Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z

果断删除javaee.jar包,但是我是JAVAEE的项目,这时候又会缺失某些类。

我们可以根据需要将某些类引入进来,我这里用到了javax.servlet,javax.servlet.jsp,于是将这两个引进来,问题解决了。

    <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>servlet-api</artifactId>
          <version>3.0-alpha-1</version>
        </dependency>
        <dependency>
          <groupId>javax.servlet.jsp</groupId>
          <artifactId>javax.servlet.jsp-api</artifactId>
          <version>2.2.1</version>
   </dependency>

猜你喜欢

转载自chenhongbinjs.iteye.com/blog/1672682