代码生成时无法找到Hibernate MultiMap

cls*_*tek 6 java apache hibernate jpa maven

虽然我正在尝试使用现有的db关系通过Hibernate生成一些类,但它会产生一些错误:

org.hibernate.console.HibernateConsoleRuntimeException: Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
org.hibernate.console.HibernateConsoleRuntimeException: Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class
java.lang.NoClassDefFoundError: org/apache/commons/collections/MultiMap
org/apache/commons/collections/MultiMap
java.lang.ClassNotFoundException: org.apache.commons.collections.MultiMap cannot be found by org.jboss.tools.hibernate.runtime.v_5_1_5.0.1.Final-v20160331-1852-B88
org.apache.commons.collections.MultiMap cannot be found   byorg.jboss.tools.hibernate.runtime.v_5_1_5.0.1.Final-v20160331-1852-B88
Run Code Online (Sandbox Code Playgroud)

我的maven文件:

<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.3</version>
    <configuration>
      <source>1.8</source>
      <target>1.8</target>
    </configuration>
  </plugin>
</plugins>
</build>
<dependencies>
<dependency>
    <groupId>org.firebirdsql.jdbc</groupId>
    <artifactId>jaybird-jdk18</artifactId>
    <version>2.2.10</version>
</dependency>
<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-core</artifactId>
   <version>5.1.0.Final</version>
</dependency>
<dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>3.2.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我在Maven Dependencies中看到了apache common-collections jar,我可以在我的代码中使用apache的MultiMap.

Gor*_* Ma 3

我遇到过同样的问题。以下是我修复它的方法:打开“编辑配置”对话框并转到“类路径”选项卡,删除项目名称(默认类路径),单击“添加项目...”按钮添加您的项目。然后就可以了。

或者您可以尝试使用以前的版本而不是 v5.1。在 hibernate 视角中,“您的配置”/编辑配置,将 hibernate 版本更改为以前的版本,例如 v4.3。