【发布时间】:2019-08-02 13:28:02
【问题描述】:
我已经开始使用带有 Hazelcast 实现的 JCache。
当我尝试将对象放入缓存时,我收到以下错误:
引起:java.io.NotSerializableException:com.catenic.anafee.common.type.CaBigNumber$$Lambda$131/1884551977
<pre style='text-align: left; border: 1px dashed #008DEF; line-height: 18px; padding: 15px; font-size: 13px; font-family:'Courier New', Courier, monospace; overflow: auto;'>CaLpgDataCollectionDto<**CaBigNumber**> lpgDatasource = <span style='font-weight:bold;color:#7B0052;'>new</span> CaLpgDataCollectionDto<>();</pre>
<br>
<pre style='text-align: left; border: 1px dashed #008DEF; line-height: 18px; padding: 15px; font-size: 13px; font-family:'Courier New', Courier, monospace; overflow: auto;'><span style='font-weight:bold;color:#7B0052;'>public</span> <span style='font-weight:bold;color:#7B0052;'>class</span> CaLpgDataCollectionDto<T> <span style='font-weight:bold;color:#7B0052;'>implements</span> Serializable
<span style='font-weight:bold;color:#D3171B'>{</span>
<span style='font-weight:bold;color:#7B0052;'>private</span> <span style='font-weight:bold;color:#7B0052;'>static</span> <span style='font-weight:bold;color:#7B0052;'>final</span> <span style='font-weight:bold;color:#7B0052;'>long</span> serialVersionUID = -1L;
<br>
<span style='font-weight:bold;color:#7B0052;'>private</span> List<CaLpgDataRowDto<T>> dataRows = <span style='font-weight:bold;color:#7B0052;'>new</span> ArrayList<>();</pre>
<pre style='text-align: left; border: 1px dashed #008DEF; line-height: 18px; padding: 15px; font-size: 13px; font-family:'Courier New', Courier, monospace; overflow: auto;'><span style='font-weight:bold;color:#7B0052;'>public</span> <span style='font-weight:bold;color:#7B0052;'>class</span> CaLpgDataRowDto<T> <span style='font-weight:bold;color:#7B0052;'>implements</span> Serializable
<span style='font-weight:bold;color:#D3171B'>{</span>
<span style='font-weight:bold;color:#7B0052;'>private</span> <span style='font-weight:bold;color:#7B0052;'>static</span> <span style='font-weight:bold;color:#7B0052;'>final</span> <span style='font-weight:bold;color:#7B0052;'>long</span> serialVersionUID = 1L;</pre>
<pre style='text-align: left; border: 1px dashed #008DEF; line-height: 18px; padding: 15px; font-size: 13px; font-family:'Courier New', Courier, monospace; overflow: auto;'><span style='font-weight:bold;color:#7B0052;'>public</span> <span style='font-weight:bold;color:#7B0052;'>class</span> CaBigNumber <span style='font-weight:bold;color:#7B0052;'>extends</span> Number <span style='font-weight:bold;color:#7B0052;'>implements</span> Comparable<CaBigNumber>
<span style='font-weight:bold;color:#D3171B'>{</span></pre>
<pre style='text-align: left; border: 1px dashed #008DEF; line-height: 18px; padding: 15px; font-size: 13px; font-family:'Courier New', Courier, monospace; overflow: auto;'>CachingProvider cachingProvider = Caching.getCachingProvider();
CacheManager cacheManager = cachingProvider.getCacheManager();
CompleteConfiguration<String, Object> config =
<span style='font-weight:bold;color:#7B0052;'>new</span> MutableConfiguration<String, Object>().setTypes(String.class, Object.class);
Cache<String, Object> cache = cacheManager.createCache( <span style='color:#2A00FF'>"lpgcache"</span>, config );
**cache.put**( <span style='color:#2A00FF'>"**lpgDatasource**"</span>, lpgDatasource );</pre>
你能帮帮我吗?
【问题讨论】:
-
请看code formatting guide,您不必像以前那样在html sn-p 中格式化。如果syntax-highlighting 与您的标签不同或者您有多个语言标签,您也可以设置正确的syntax-highlighting