class file for org.apache.shiro.lang.util.Nameable not found class file for org.apache.shiro.lang.util.Nameable not found
web.xml 需要升级一下shiro的jar包
原先是:
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>1.7.1</version>
</dependency>
改成:
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring-boot-web-starter</artifactId>
<version>2.0.5</version>
</dependency>
结果mvn clean install时报错
Compilation failure: Compilation failure: [ERROR] /Users/gaoxianghu/temp/git/server-daogou/web/src/main/java/com/davidhu/shopguide/web/config/shiro/JwtFilter.java:[12,8] cannot access org.apache.shiro.lang.util.Nameable [ERROR] class file for org.apache.shiro.lang.util.Nameable not found
问题是 JwtFilter.java这里根本没有用到 Nameable这个类。
搜了一下,网上遇到的大多数和IDEA有关,invalid Cache and restart 可以解决或者重新生成.iml,清理 .idea目录啊可以解决。可惜我和IDEA无关,是发生在maven 编译时报错 (https://stackoverflow.com/questions/38549649/java-cannot-access-class-class-file-not-found)
搜下Nameable这个类。 层级大概是 shiro-redis-3.3.1 -> shiro-core-1.6 ->shiro-lang-1.6 -> Nameable
但shiro-core为什么没用 shiro-spring-boot-web-starter里的?反正后来改用2.0.5就可以了。改成下面的配置
<dependency>
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<artifactId>shiro-core</artifactId>
<groupId>org.apache.shiro</groupId>
</exclusion>
</exclusions>
</dependency>
至于为什么用shiro-core-1.6 的不行,这个还没搞清楚
喜欢艺术的码农

浙公网安备 33010602011771号