Jackson 支持
Spring Security 为持久化 Spring Security 相关类提供了 Jackson 支持。在使用分布式会话(会话复制、Spring Session 等)时,这可以提高 Spring Security 相关类的序列化性能。
要使用它,请将 SecurityJackson2Modules.getModules(ClassLoader)
注册到 ObjectMapper
中 (jackson-databind)
ObjectMapper mapper = new ObjectMapper();
ClassLoader loader = getClass().getClassLoader();
List<Module> modules = SecurityJackson2Modules.getModules(loader);
mapper.registerModules(modules);
// ... use ObjectMapper as normally ...
SecurityContext context = new SecurityContextImpl();
// ...
String json = mapper.writeValueAsString(context);
以下 Spring Security 模块提供 Jackson 支持
|