Commit 46d8187c authored by 技术部-任文超's avatar 技术部-任文超

这样用

new StringRedisTemplate().opsForValue().increment(key, 1L);
是不对的,因为
JedisDataException: ERR value is not an integer or out of range
parent 453e66a2
...@@ -119,9 +119,9 @@ public class RedisConfig { ...@@ -119,9 +119,9 @@ public class RedisConfig {
} }
@Bean(name = "stringRedisTemplate") @Bean(name = "stringRedisTemplate")
public StringRedisTemplate stringRedisTemplate( public RedisTemplate<String, String> stringRedisTemplate(
RedisConnectionFactory factory) { RedisConnectionFactory factory) {
final StringRedisTemplate template = new StringRedisTemplate(); final RedisTemplate<String, String> template = new RedisTemplate<>();
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
JdkSerializationRedisSerializer jdkSerializationRedisSerializer = new JdkSerializationRedisSerializer(); JdkSerializationRedisSerializer jdkSerializationRedisSerializer = new JdkSerializationRedisSerializer();
template.setEnableTransactionSupport(false); template.setEnableTransactionSupport(false);
......
...@@ -16,6 +16,7 @@ import io.swagger.annotations.ApiParam; ...@@ -16,6 +16,7 @@ import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -36,7 +37,7 @@ public class UserApiController { ...@@ -36,7 +37,7 @@ public class UserApiController {
private ISessionService sessionService; private ISessionService sessionService;
@Resource @Resource
@Qualifier("stringRedisTemplate") @Qualifier("stringRedisTemplate")
private StringRedisTemplate stringRedisTemplate; private RedisTemplate<String, String> stringRedisTemplate;
@Resource @Resource
private ISmsService smsService; private ISmsService smsService;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment