问题描述:
java.lang.NoSuchMethodError: redis.clients.jedis.ScanResult.getStringCursor()Ljava/lang/String;
at org.crazycake.shiro.BaseRedisManager.keys(BaseRedisManager.java:148) ~[shiro-redis-3.1.0.jar:na]
at org.crazycake.shiro.RedisSessionDAO.getActiveSessions(RedisSessionDAO.java:103) ~[shiro-redis-3.1.0.jar:na]
at com.yuhua.shiro.common.util.ShiroUtils.deleteCache(ShiroUtils.java:67) ~[classes/:na]
at com.yuhua.shiro.common.shiro.auth.ShiroRealm.doGetAuthenticationInfo(ShiroRealm.java:93) ~[classes/:na]
at org.apache.shiro.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:571) ~[shiro-core-1.4.0.jar:1.4.0]
at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doSingleRealmAuthentication(ModularRealmAuthenticator.java:180) ~[shiro-core-1.4.0.jar:1.4.0]
at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:267) ~[shiro-core-1.4.0.jar:1.4.0]
问题原因:spring-boot-starter-parent版本与shiro-redis版本不匹配,作者前者使用版本2.2.5,后者使用版本3.1.0,两者不匹配。
解决方式:亲测shiro-redis3.1.0对应spring-boot-starter-parent2.1.5 可解决问题。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<!-- Shiro-redis插件 -->
<dependency>
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis</artifactId>
<version>3.1.0</version>
</dependency>