springboot2+Hibernate报错:java.lang.AbstractMethodError nullSafeGet

背景:

        为引入某组件,将springboot版本由1.x升级到2.0.8,升级后springboot启动报错

错误堆栈:

java.lang.AbstractMethodError
at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:119)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:82)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2854)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1747)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1673)
at org.hibernate.loader.Loader.getRow(Loader.java:1562)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:732)
at org.hibernate.loader.Loader.processResultSet(Loader.java:991)
at org.hibernate.loader.Loader.doQuery(Loader.java:949)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)
at org.hibernate.loader.Loader.doList(Loader.java:2692)
at org.hibernate.loader.Loader.doList(Loader.java:2675)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2507)
at org.hibernate.loader.Loader.list(Loader.java:2502)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:392)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1489)
at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445)
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414)
 

org.jasypt.hibernate4.type.EncryptedStringType.nullSafeGet(Ljava/sql/ResultSet;[Ljava/lang/String;Lorg/hibernate/engine/spi/SharedSessionContractImplementor;Ljava/lang/Object;)Ljava/lang/Object; java.lang.AbstractMethodError: org.jasypt.hibernate4.type.EncryptedStringType.nullSafeGet(Ljava/sql/ResultSet;[Ljava/lang/String;Lorg/hibernate/engine/spi/SharedSessionContractImplementor;Ljava/lang/Object;)Ljava/lang/Object; at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:119) at org.hibernate.type.AbstractType.hydrate(AbstractType.java:82) at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2854) at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1747) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1673) at org.hibernate.loader.Loader.getRow(Loader.java:1562) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:732) at org.hibernate.loader.Loader.processResultSet(Loader.java:991) at org.hibernate.loader.Loader.doQuery(Loader.java:949) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341) at org.hibernate.loader.Loader.doList(Loader.java:2692) at org.hibernate.loader.Loader.doList(Loader.java:2675) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2507) at org.hibernate.loader.Loader.list(Loader.java:2502) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:392) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1489) at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1445) at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1414) at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1463)

报错原因:

https://discourse.hibernate.org/t/java-lang-abstractmethoderror-at-org-hibernate-type-customtype-nullsafeget/780

由于项目中使用jasypt包里的EncryptedStringType类中需要对String字段进行处理,springboot2升级后与jasypt-hibernate4中的部分类不兼容导致org.hibernate.type.CustomType.nullSafeGet无法通过反射得到

解决方案:

springboot1.x升级2.x后,在gradle文件中将jasypt由hibernate4升级到hibernate5,同时注意采用1.9.3版本

compile('org.jasypt:jasypt-hibernate5:1.9.3')

同时修改项目中import了hibernate4的代码改为hibernate5

---------------------------------------------------------------------------------------------------------------------------------升级springboot2后如果遇到gradle构建报错 ‘找不到符号’,可参考如下链接

https://blog.csdn.net/Shaochen_/article/details/80263768#commentBox

 

 

你可能感兴趣的:(springboot)