gpt4 book ai didi

java - EhCache,堆上层 : No serializer found

转载 作者:行者123 更新时间:2023-12-02 11:19:17 28 4
gpt4 key购买 nike

我需要堆上缓存,所以我尝试使用 ehcache v3.5.2

我有下一个测试:

public class TestEhCache {
public static class MyObj {
String message;

public MyObj(String message) {
this.message = message;
}
}

@Test
public void testDebugLogs() {
CacheManager cacheManager;

cacheManager = CacheManagerBuilder.newCacheManagerBuilder().build();
cacheManager.init();

Cache<String, MyObj> myCache = cacheManager.createCache("myCache",
CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, MyObj.class, ResourcePoolsBuilder.heap(3))
.build());
}

}

结果我看到了下一个警告

2018-04-26 19:56:26,237 [main] DEBUG org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider - Serializer for <java.lang.String> : org.ehcache.impl.serialization.StringSerializer@365185bd
2018-04-26 19:56:26,238 [main] DEBUG org.ehcache.core.EhcacheManager - Could not create serializers for myCache
org.ehcache.spi.serialization.UnsupportedTypeException: No serializer found for type 'it.TestEhcache$MyObj'
at org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider.getSerializerClassFor(DefaultSerializationProvider.java:136)
at org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider.createSerializer(DefaultSerializationProvider.java:98)
at org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider.createValueSerializer(DefaultSerializationProvider.java:90)
at org.ehcache.core.EhcacheManager.getStore(EhcacheManager.java:477)
at org.ehcache.core.EhcacheManager.createNewEhcache(EhcacheManager.java:316)
at org.ehcache.core.EhcacheManager.createCache(EhcacheManager.java:265)
at org.ehcache.core.EhcacheManager.createCache(EhcacheManager.java:243)
at it.TestEhcache.testDebugLogs(TestEhcache.java:29)
2018-04-26 19:56:26,243 [main] DEBUG org.ehcache.impl.internal.spi.copy.DefaultCopyProvider - Copier for <java.lang.String> : org.ehcache.impl.copy.IdentityCopier@150c158
2018-04-26 19:56:26,244 [main] DEBUG org.ehcache.impl.internal.spi.copy.DefaultCopyProvider - Copier for <it.TestEhcache$MyObj> : org.ehcache.impl.copy.IdentityCopier@4524411f
2018-04-26 19:56:26,292 [main] DEBUG class org.ehcache.core.Ehcache-myCache - Initialize successful.
2018-04-26 19:56:26,292 [main] INFO org.ehcache.core.EhcacheManager - Cache 'myCache' created in EhcacheManager.

如何抑制“未找到类型的序列化程序”警告?据我了解,无堆层不需要它。 (参见 Louis 的 Jacomet 回复 here )

最佳答案

降低日志级别 - 这是在 DEBUG 时打印的,因此从技术上讲它不是警告。

事实上,你的堆上缓存会正常工作。

关于java - EhCache,堆上层 : No serializer found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50045076/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com