隔壁村长 2022-02-21 11:28 采纳率: 50%
浏览 75
已结题

springboot使用shiro框架启动报错

springboot+jwt+shiro
@Bean
public ShiroFilterFactoryBean getShiroFilterFactoryBean(DefaultWebSecurityManager defaultWebSecurityManager,JwtFilter jwtFilter){
    ShiroFilterFactoryBean FilterFactoryBean = new ShiroFilterFactoryBean();
    FilterFactoryBean.setSecurityManager(defaultWebSecurityManager);
    Map<String, Filter> filterMap=new HashMap<>();
    filterMap.put("jwt",jwtFilter);
    //添加过滤器
    FilterFactoryBean.setFilters(filterMap);
    Map<String,String> map=new LinkedHashMap<>();
    //避免swagger被拦截
    map.put("/swagger-ui.html**", "anon");
    map.put("/v2/api-docs", "anon");
    map.put("/swagger-resources/**", "anon");
    map.put("/webjars/**", "anon");

    map.put("/**","jwt");
    FilterFactoryBean.setFilterChainDefinitionMap(map);
    FilterFactoryBean.setLoginUrl("/user/login");
    return FilterFactoryBean;

}

@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {

    JwtToken jwtToken = (JwtToken)token;
    String jwt = (String) jwtToken.getPrincipal();
    Claims claims = JwtUtil.parseJWT(jwt);
    String username = claims.getId();
    User userByUsername = userServive.getUserByUsername(username);
    if(userByUsername==null){
        return null;
    }
    return new SimpleAuthenticationInfo(username,userByUsername.getPassword(),getName());
}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.15.jar:5.3.15]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656) ~[spring-beans-5.3.15.jar:5.3.15]
... 34 common frames omitted
我的解答思路和尝试过的方法
我想要达到的结果
  • 写回答

2条回答

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 系统已结题 3月3日
      • 已采纳回答 2月23日
      • 创建了问题 2月21日

      悬赏问题

      • ¥15 请问这个脚本bat清除tmp文件,会导致硬盘文件损坏吗?(操作系统-windows)
      • ¥15 IncredBuild报错
      • ¥15 锂电池偏最小二乘法参数辩识
      • ¥20 有偿求 matlab解GP方程程序
      • ¥15 session失效问题
      • ¥15 GMS地下水数值模拟无法打开
      • ¥15 树型结构的数据怎么匹配分支
      • ¥15 stm32F4用.引不出来结构体成员怎么解决
      • ¥30 Syntax Error: TypeError: this.getOptions is not a function的问题
      • ¥15 eclipse Android环境搭建