简介
当一个类的对象需要被序列化时,但是某些属性不需要被序列化,这时不需要序列化的属性可以使用关键字transient 修饰。
只要被关键字transient 修饰了,序列化时这个属性就不会被序列化了。同时静态修饰也不会被序列化,因为序列化是把对象数据进行持久化存储,而静态的属于类加载时的数据,不会被序列化。
Dubbo是阿里巴巴在2011年开源的的分布式服务框架,是SOA服务化治理方案的核心框架。
Dubbo的整体架构如下:
Dubbo主要提供三个方面的功能:
首先准备环境,需要安装Zookeeper。详细的Zookeeper信息可以看我的另一篇博客。
1 | import graphql.ExecutionResult; |
今天要说的是JavaScript的闭包问题,先来看代码:
1 | <script type="text/javascript"> |
话不多说,先看异常:
1 | 1 HTTP Status 500 - Could not write content: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0]->com.agen.entity.User["positionchanges"]->org.hibernate.collection.internal.PersistentSet[0]->com.agen.entity.Positionchange["position"]->com.agen.entity.Position_$$_jvst714_7["handler"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0]->com.agen.entity.User["positionchanges"]->org.hibernate.collection.internal.PersistentSet[0]->com.agen.entity.Positionchange["position"]->com.agen.entity.Position_$$_jvst714_7["handler"]) |
网上找到的解决办法说是因为,hibernate会给每一个被管理的对象加上hibernateLayInitializer属性,同时structs-jsonplugin或者其他的jsonplugin都是。
因为jsonplugin用的是java的”内审机制”,hibernate会给被管理的pojo加入一个hibernateLayInitializer属性,jsonplugin通过java的反射机制将pojo解析为json时,
同时hibernateLazyInitializer属性也进行反射操作,但是hibernateLazyIniyializer无法由反射得到,所以就抛出了异常。