使用Eclipse的hibernate插件进行工程反转生成po类Could not initialize class org.hibernate.cfg.reveng.OverrideReposity
来源:互联网 发布:淘宝客优惠券网站建站 编辑:程序博客网 时间:2024/06/05 10:45
hibernate插件是适合Eclipse版本的最新版本,工程反转使用的hibernate3.6
使用Eclipse的hibernate插件进行工程反转生成po类时报错:
org.hibernate.console.HibernateConsoleRuntimeException: Received a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same classReceived a NoClassDefFoundError, probably the console configuration classpath is incomplete or contains conflicting versions of the same class java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.reveng.OverrideRepository Could not initialize class org.hibernate.cfg.reveng.OverrideRepository java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.reveng.OverrideRepository Could not initialize class org.hibernate.cfg.reveng.OverrideRepository
查了很多资料,有人说是jar包冲突,但是这里设置了buildpath(只将hibernate3.jar,jdbc驱动,hibernate方言包加入buildpath中),删除了所有可能冲突的jar包问题仍问解决。
最终发现问题出在设置的hibernate.reveng.xml文件。
如果不设置reveng.xml文件,则文件找不到的问题消失,改成出现如下问题。
org.hibernate.cfg.JDBCBinderException: Duplicate class name com.pepspb.entity.CheckConstraints generated for org.hibernate.mapping.Table(test.student). Same name where generated for org.hibernate.mapping.Table(test.student)Duplicate class name 'com.pepspb.entity.CheckConstraints generated for org.hibernate.mapping.Tabletest.student). Same name where generated for org.hibernate.mapping.Table(test.student)<No message>
这个问题是由于数据库中存在多个模式中有相同的表
查看数据库连接,显示设置的连接下不仅包含我们需要的模式Militaryms_v2,还包括其他模式,而其模式中存在与该模式相同的表名。
hibernate.reveng.xml就是用来配置工程反转的表和模式,这里没有设置该文件,所以会发现同名的表。
解决方法一:不添加hibernate.reveng.xml文件,数据库中不同模式下设置成不同表名。
解决方法二:配置buildpath,换成hibernate3.5.jar包(hibernate3.5可以正常生成hibernate.reveng.xml文件),jdbc驱动以及相应的方言包。
hibernate.reveng.xml文件:<hibernate-reverse-engineering> < table-filter match-name= "asroc"/> //如果数据库中不同模式下有相同表名,那么不设置模式会出现上述类名重复问题</hibernate-reverse-engineering>
hibernate3.5版本生成hibernate.reveng.xml文件正常,可以设置schema为项目中需要的模式。
配置文件即改为:
< hibernate-reverse-engineering> < table-filter match-schema = "MILITARYMS_V2" match-name= "asroc" /></ hibernate-reverse-engineering>
至此,该问题解决。
0 0
- 使用Eclipse的hibernate插件进行工程反转生成po类Could not initialize class org.hibernate.cfg.reveng.OverrideReposity
- java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.cfg.AnnotationConfiguration
- Could not instantiate bean class [org.hibernate.cfg.Configuration]: Construct
- org.hibernate.LazyInitializationException:could not initialize proxy
- org.hibernate.LazyInitializationException: could not initialize proxy
- org.hibernate.LazyInitializationException: could not initialize proxy
- org.hibernate.LazyInitializationException: could not initialize proxy
- org.hibernate.LazyInitializationException: could not initialize proxy
- org.hibernate.LazyInitializationException: could not initialize proxy
- org.hibernate.LazyInitializationException: could not initialize proxy
- hibernate org.hibernate.validator.util.Version <clinit> Could not initialize class错误
- org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
- Hibernate 异常org.hibernate.LazyInitializationException: could not initialize prox
- Hibernate 异常org.hibernate.LazyInitializationException: could not initialize prox
- org.hibernate.PropertyNotFoundException: Could not find a getter for titlse in class com.po.Intro
- org.hibernate.PropertyNotFoundException: Could not find a getter for titlse in class com.po.Intro异常
- SSH配置启动后Tomcat后报错:Could not instantiate bean class [org.hibernate.cfg.Configuration]
- could not initialize proxy - no Session - Class: org.hibernate.proxy.AbstractLazyInitializer
- java web.xml welcome-file-list的默认值
- 遗传算法简单实例
- 网传花生壳内网版即将全面嵌入路由器?
- layout文件下面的文件在R.java中没生成对应id
- KVM虚拟机网络配置 Bridge方式,NAT方式
- 使用Eclipse的hibernate插件进行工程反转生成po类Could not initialize class org.hibernate.cfg.reveng.OverrideReposity
- Android用SurfaceView播放本地视屏(音频)文件
- html 字体 进行设置
- Eclipse插件SVN修改密码的方法
- Java内部类
- Hadoop 的HA高可集群用性
- tcp socket粘包分析
- 月夜花圆
- 哥舒歌