我使用下面的插件来生成我的实体类。当我执行命令mvn hibernate 3:hbm2 java时,我得到了这个错误:
创建AntRun任务时出错。:发生Ant BuildException:java.lang.NoClassDefFoundError:org/hibernate/engine/Mapping:org.hibernate.engine.Mapping
我尝试了每个hibernate版本,但我找不到包含指定类的版本。
使用JDK 11。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>3.0</version>
<executions>
<execution>
<id>generate-entities</id>
<phase>post-clean</phase>
<goals>
<goal>hbm2java</goal>
</goals>
</execution>
</executions>
<configuration>
<hibernatetool destdir="${project.build.sourceDirectory}">
<classpath>
<path location="${project.build.sourceDirectory}/classes"/>
</classpath>
<!--<configuration configurationfile="src/main/resources/hibernate/hibernate.cfg.xml"/> -->
<jdbcconfiguration
packagename="com.cm.sourcegenerator"
revengfile="src/main/resources/hibernate/hibernate.reveng.xml"
/>
<hbm2java jdk5="true" ejb3="true"/>
<!--<hbm2cfgxml ejb3="true" destdir="${basedir}/src/main/resources/hibernate" /> -->
</hibernatetool>
</configuration>
<dependencies>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.33</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>${cglib.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.11.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.11.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>
</dependencies>
</plugin>
1条答案
按热度按时间7cjasjjr1#
Mapping接口在Hibernate 4和更高版本中被删除。相反,您可以使用MetadataImplementor接口来访问实体的元数据。
如果你使用Hibernate 4。3.11.最后,您可以尝试更改hibernate 3-maven-plugin配置以使用MetadataSources工具而不是HibernateTool。您可以将当前配置替换为: