io.lettuce.core.RedisCommandExecutionException: ERR unknown command 'GEOADD' at io.lettuce.core.ExceptionFactory.createExecutionException(ExceptionFactory.java:) ~[lettuce-core-.RELEASE.jar:na] at io.lettuce.core.ExceptionFactory.createExecutionException(ExceptionFactory.java:) ~[lettuce-core-.RELEASE.jar:na] at io.lettuce.core.protocol.AsyncCommand.completeResult(AsyncCommand.java:) ~[lettuce-core-.RELEASE.jar:na] at io.lettuce.core.protocol.AsyncCommand.complete(AsyncCommand.java:) ~[lettuce-core-.RELEASE.jar:na] at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:) ~[lettuce-core-.RELEASE.jar:na] at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:) ~[lettuce-core-.RELEASE.jar:na] at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:) ~[lettuce-core-.RELEASE.jar:na] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:) ~[netty-all-.Final.jar:.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:) ~[netty-all-.Final.jar:.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:) ~[netty-all-.Final.jar:.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:) ~[netty-all-.Final.jar:.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:) ~[netty-all-.Final.jar:.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:) ~[netty-all-.Final.jar:.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:) ~[netty-all-.Final.jar:.Final] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:) ~[netty-all-.Final.jar:.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:) ~[netty-all-.Final.jar:.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:) ~[netty-all-.Final.jar:.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:) ~[netty-all-.Final.jar:.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:) ~[netty-all-.Final.jar:.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$.run(SingleThreadEventExecutor.java:) ~[netty-all-.Final.jar:.Final] at io.netty.util..run(ThreadExecutorMap.java:) ~[netty-all-.Final.jar:.Final] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:) ~[netty-all-.Final.jar:.Final] at java.lang.Thread.run(Thread.java:) [na:1.8.0_191]
再看接口代码:
@RequestMapping(value = "/s/{id}", method = RequestMethod.GET) @ResponseBody public void detail22(@PathVariable Long id) { /* Cursor scan = redisTemplate.opsForHash().scan("1", ScanOptions.NONE); Set<String> keys = redisTemplate.keys("1111"); for(String key:keys){ System.out.println(key); }*/ redisTemplate.boundGeoOps(").add(new Point(111.11,111.23),"cxy"); String s = redisTemplate.boundGeoOps(").toString(); System.out.println(s); }
这段代码是在操作redis的geo数据类型,再看我的redis版本:3.0.504 这个是比较久的版本,不支持geo数据类型,所以报错,geo的数据类型是在redis3.2版本以后才支持的数据类型,所以需要切换一个redis的版本