我正在使用带有Redis的spring boot和spring security。如果我在带有eclipse的eclipse中运行spring boot app没关系,但是当在tomcat上运行war文件时,出现错误:
java.lang.NoSuchMethodError: org.springframework.data.redis.core.RedisOperations.delete(Ljava / lang / Object;)V 在org.springframework.session.data.redis.RedisSessionExpirationPolicy.cleanExpiredSessions(RedisSessionExpirationPolicy.java:132) 〜[spring-session-1.3.3.RELEASE.jar:na] 在org.springframework.session.data.redis.RedisOperationsSessionRepository.cleanupExpiredSessions(RedisOperationsSessionRepository.java:398) 〜[spring-session-1.3.3.RELEASE.jar:na] 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)〜[na:1.8.0_151] 在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 〜[na:1.8.0_151] 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 〜[na:1.8.0_151] 在java.lang.reflect.Method.invoke(Method.java:498)〜[na:1.8.0_151] 在org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) 〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] 在org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) 〜[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] 在org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93) [spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE] 在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511) [na:1.8.0_151] 在java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_151] 在java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.access $ 201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_151] 在java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_151] 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_151] 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_151] 在java.lang.Thread.run(Thread.java:748)[na:1.8.0_151]
redis的会话配置
DoubleAnimation
依赖性:
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 1800)
public class HttpSessionConfig {
@Bean
public LettuceConnectionFactory connectionFactory() {
return new LettuceConnectionFactory();
}
@Bean
public static ConfigureRedisAction configureRedisAction() {
return ConfigureRedisAction.NO_OP;
}
@Bean
public HttpSessionIdResolver httpSessionIdResolver() {
return HeaderHttpSessionIdResolver.xAuthToken();
}
}