- 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积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部

