public void testRedisListPop() {
String redisKey = "testGoodsKey";
// 使用管道从redis list结构中批量获取元素
List objects = redisTemplate.executePipelined((RedisConnection redisConnection) -> {
// 打开管道
redisConnection.openPipeline();
for (int i = 0; i < 2; i++) {
redisConnection.rPop(redisKey.getBytes());
}
return null;
});
System.out.println(objects);
}
报错详情:反序列化失败
org.springframework.data.redis.serializer.SerializationException: Cannot deserialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.StreamCorruptedException: invalid stream header: 31303030 ... Caused by: org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.StreamCorruptedException: invalid stream header: 31303030 at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:78) at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:36) at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.deserialize(JdkSerializationRedisSerializer.java:80) ... 39 more Caused by: java.io.StreamCorruptedException: invalid stream header: 31303030 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:899) at java.io.ObjectInputStream.(ObjectInputStream.java:357) at org.springframework.core.ConfigurableObjectInputStream.(ConfigurableObjectInputStream.java:63) at org.springframework.core.ConfigurableObjectInputStream.(ConfigurableObjectInputStream.java:49) at org.springframework.core.serializer.DefaultDeserializer.deserialize(DefaultDeserializer.java:68) at org.springframework.core.serializer.support.DeserializingConverter.convert(DeserializingConverter.java:73) ... 41 more
JSR-303是一个数据验证的规范,但是spring并没有对其进行实现,Hibernate Validator是实现了这一规范的,通过此这个实现来讲SpringMVC对JSR-303的支持。
JSR-303的校验是基于注解的,首先要把这些注解标记在需要验证的实体类的属性上或是其对应的get方法上。
登录需要验证类
public class Login {
@NotEmpty
引言:有时候需要在项目初始化的时候进行一系列工作,比如初始化一个线程池,初始化配置文件,初始化缓存等等,这时候就需要用到启动监听器,下面分别介绍一下两种常用的项目启动监听器
ServletContextListener
特点: 依赖于sevlet容器,需要配置web.xml
使用方法:
public class StartListener implements
The next group of methods has to do with rounding decimal values into integers. Three methods — Math.ceil(), Math.floor(), and Math.round() — handle rounding in differen