账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    No bean named 'springSessionRepositoryFilter' is defined
    18
    0

    使用spring-session配置了Filter之后报错,我使用的是Java配置,以下是我的配置

    public class ManagementWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
    
        protected Class<?>[] getRootConfigClasses() {
            return new Class[]{RootConfig.class};
        }
    
        protected Class<?>[] getServletConfigClasses() {
            return new Class[]{ServletConfig.class};
        }
    
        protected String[] getServletMappings() {
            return new String[]{"/"};
        }
    
    }
    @ComponentScan(basePackages = {"com.pb.configuration"})
    @Configuration
    @PropertySource("classpath:redis.properties")
    public class RootConfig {
    
    
        @Value("${redis_hostName}")
        private String hostname;
        @Value("${redis_port}")
        private String port;
        @Value("${redis_password}")
        private String password;
        @Value("${redis_timeout}")
        private String timeout;
    
        @Bean
        public JedisPoolConfig jedisPoolConfig(){
            JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
            jedisPoolConfig.setMaxIdle(10);
            jedisPoolConfig.setMaxTotal(100);
            return jedisPoolConfig;
        }
    
        @Bean
        public JedisConnectionFactory jedisConnectionFactory(JedisPoolConfig jedisPoolConfig)
        {
            JedisConnectionFactory factory = new JedisConnectionFactory();
            factory.setPoolConfig(jedisPoolConfig);
            factory.setHostName(hostname);
            factory.setPort(Integer.parseInt(port));
            factory.setPassword(password);
            factory.setTimeout(Integer.parseInt(timeout));
            factory.setUsePool(true);
            return factory;
        }
    
        @Bean
        public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
            return new PropertySourcesPlaceholderConfigurer();
        }
        
        @Bean
        public RedisHttpSessionConfiguration redisHttpSessionConfiguration(){
            RedisHttpSessionConfiguration redisHttpSessionConfiguration =   new RedisHttpSessionConfiguration();
            redisHttpSessionConfiguration.setMaxInactiveIntervalInSeconds(600);
            return redisHttpSessionConfiguration;
        }
    }
    @ComponentScan(basePackages = {"com.pb"})
    @Configuration
    @EnableWebMvc
    public class ServletConfig extends WebMvcConfigurerAdapter{
    
    
        @Bean
        public ViewResolver viewResolver(){
            InternalResourceViewResolver resolver = new InternalResourceViewResolver();
            resolver.setPrefix("/WEB-INF/views/");
            resolver.setSuffix(".jsp");
            return  resolver;
        }
    
        @Override
        public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
            configurer.enable();
        }
    }
    public class WebApplication implements WebApplicationInitializer {
        public void onStartup(ServletContext servletContext) throws ServletException {
            javax.servlet.FilterRegistration.Dynamic springSessionRepositoryFilter =   servletContext.addFilter("springSessionRepositoryFilter",DelegatingFilterProxy.class);
            springSessionRepositoryFilter.addMappingForUrlPatterns(null,false,"/*");
        }
    }
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 草生 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部