昨天在写entity类时,在运行jetty时出错
java
16:01:39,782 ERROR JavassistLazyInitializer:166 - HHH000142: Javassist Enhancement failed: com.highrace.car.model.CarLicence java.lang.RuntimeException: duplicate method: getHandler in com.highrace.car.model.CarLicence_$$_javassist_30 at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:510) at javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:487) at javassist.util.proxy.ProxyFactory.createClass1(ProxyFactory.java:423) at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:395) ...... Caused by: javassist.bytecode.DuplicateMemberException: duplicate method: getHandler in com.highrace.car.model.CarLicence_$$_javassist_30 ......
我反反复复的检查entity类,发现并无配置错误,最后错误定位到javassist包下面应该有getHandler与个人getHandler方法冲突spring
在网上查找方法sql
第一种,将默认的javassist改为cglib,ide
一、导入cglib-nobep-2.2.net
二、在hibernate.properties文件中加入hibernate
hibernate.bytecode.provider=cglib
<property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">false</prop> <!-- 因为个人hibernate是与spring集成的因此没有hibernate.properties文件 只能在这加这两条配置 --> <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop> <prop key="hibernate.bytecode.provider">cglib</prop> </props> </property>
http://stackoverflow.com/questions/2269185/duplicate-method-error-when-using-hibernate-javassist-gileadorm
第一种没成功。get
第二种,通过个人反复查找,网上有人说这是javassist的一个bug,说后续版本可能会解决这个bug,因而我添加了下面的版本替换以前的版本,问题解决了。it
<dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> <version>3.18.2-GA</version> </dependency>