我刚刚通过Maven导入了Redisson 1.0.3,在默认端口上的本地主机上设置了Redis服务器,并想尝试Redisson Redis客户端。我的测试代码如下:
Redisson redis = Redisson.create(); Map m = redis.getMap("someMap");
但我得到:
java.lang.NoSuchFieldError: WRITE_BIGDECIMAL_AS_PLAIN at org.redisson.codec.JsonJacksonCodec.createObjectMapper(JsonJacksonCodec.java:90) at org.redisson.codec.JsonJacksonCodec.<init>(JsonJacksonCodec.java:43) at org.redisson.Config.<init>(Config.java:44) at org.redisson.Redisson.create(Redisson.java:85) at ...
如Redisson中的建议:WRITE_BIGDECIMAL_AS_PLAIN,我添加了依赖项:
<dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.3.3</version> </dependency>
但是没有变化…我猜想redisson的依赖关系被打破了,但是我该如何解决呢?
看来我的类路径已经包含了杰克逊的旧版本,对此进行了修复:
<!-- Redis deps --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.3.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>org.redisson</groupId> <artifactId>redisson</artifactId> <version>1.0.3</version> </dependency>