在UserDetailsService 返回的是一个 userAdminEntity,是可以存到Redis里的,在读取的时候就报错了 spring security 的报错,就是反序列化失败org.springframework.data.redis.serializer.SerializationException: Could not read JSON: The class with net.sdake.ace.admin.entity.UserAdminEntity and name of net.sdake.ace.admin.entity.UserAdminEntity is not whitelisted. If you believe this class is safe to deserialize, please provide an explicit mapping using Jackson annotations or by providing a Mixin. If the serialization is only done by a trusted source, you can also enable default typing. See https://github.com/spring-projects/spring-security/issues/4370 for details (through reference chain: org.springframework.security.core.context.SecurityContextImpl["authentication"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: The class with net.sdake.ace.admin.entity.UserAdminEntity and name of net.sdake.ace.admin.entity.UserAdminEntity is not whitelisted. If you believe this class is safe to deserialize, please provide an explicit mapping using Jackson annotations or by providing a Mixin. If the serialization is only done by a trusted source, you can also enable default typing. See https://github.com/spring-projects/spring-security/issues/4370 for details (through reference chain: org.springframework.security.core.context.SecurityContextImpl["authentication"])叫我看这个链接我也看不明白上面的序列化器是在这里找到的但是如果登录后返回的是UserDetails 的 user对象的话就完全没问题JSON反序列化是可以的。但是这样我得不到用户的信息了。如果不配置序列化器,使用默认的JDK的序列化的话,userAdminEntity是完全可以返回的请老师解答,给配个序列化器