通过redis进行会话管理以显示异常

时间:2018-06-29 07:00:35

标签: spring spring-boot redis session-management

我正在尝试使用redis管理会话。但收到以下异常

org.springframework.data.redis.serializer.SerializationException:无法序列化;嵌套的异常是org.springframework.core.serializer.support.SerializationFailedException:无法使用DefaultSerializer序列化对象。嵌套异常是java.lang.IllegalArgumentException:DefaultSerializer需要可序列化的有效负载,但收到的对象类型为[org.springframework.session.web.http.SessionRepositoryFilter $ SessionRepositoryRequestWrapper]

@SpringBootApplication
@EnableAspectJAutoProxy
@EnableCaching
@EnableRedisHttpSession
public class TsServiceApplication {

public static void main(String[] args) {
    SpringApplication.run(TsServiceApplication.class, args);
}
}

application.properties

server.port=8092
spring.redis.host=localhost
spring.redis.port=6379
spring.session.store-type=redis
spring.session.redis.namespace=spring::session

我的控制器

@Controller
@RequestMapping("/ts")
public class MainController {

@GetMapping("/{dirtid}/{carrierid}/{userid}")
public String getTemp()
        throws IOException {
System.out.println("here " + session.getId());
 session.setAttribute("name", "ak");
}


 }

0 个答案:

没有答案