hibernate3-maven-plugin生成java.lang.ClassNotFoundException:org.hibernate.util.ReflectHelper

时间:2012-11-07 16:18:59

标签: maven jpa-2.0 ddl hibernate3-maven-plugin

我正在尝试从orm.xml文件生成模式(ddl)。我正在使用hibernate3-maven-plugin。我正在使用JPA和hibernate作为实现,但我对其他实现或maven插件开放。我的pom.xml中的代码是:

 <build>
    <plugins>
        <plugin>                
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>hibernate3-maven-plugin</artifactId>
            <version>3.0</version>

            <configuration>
                <hibernatetool>
                    <jpaconfiguration persistenceunit="unitname" />

                    <hbm2ddl export="false" create="true"
                 update="true" format="true" outputfilename="schemaDiff.ddl" />

                </hibernatetool>
            </configuration>
        </plugin>            
    </plugins>
</build>

我运行的命令是:

  

mvn hibernate3:hbm2ddl -e

我收到的错误是:

  

引起:java.lang.NoClassDefFoundError:org / hibernate / util / ReflectHelper           在org.hibernate.tool.ant.JPAConfigurationTask.createConfiguration(JPAConfigurationTask.java:32)           在org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:54)           在org.hibernate.tool.ant.HibernateToolTask​​.getConfiguration(HibernateToolTask​​.java:302)           在org.hibernate.tool.ant.Hbm2DDLExporterTask.createExporter(Hbm2DDLExporterTask.java:51)           在org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)           在org.hibernate.tool.ant.HibernateToolTask​​.execute(HibernateToolTask​​.java:186)           在org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)           在java.lang.reflect.Method.invoke(Method.java:597)           在org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)           ......还有28个

     

引起:java.lang.ClassNotFoundException:org.hibernate.util.ReflectHelper           在org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)           在org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)           在org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)           ......还有40多个

1 个答案:

答案 0 :(得分:1)

George Herolyants在这里提出了一个解决方案。

http://doingenterprise.blogspot.com/2012/05/schema-generation-with-hibernate-4-jpa.html