mirror of
				https://github.com/yzcheng90/X-SpringBoot
				synced 2025-11-04 21:55:48 +08:00 
			
		
		
		
	修改redis
This commit is contained in:
		@@ -42,7 +42,7 @@ import java.util.List;
 | 
			
		||||
public class SecurityConfigurer {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private RedisTemplate<Object, Object> redisTemplate;
 | 
			
		||||
    private RedisTemplate<String, Object> redisTemplate;
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private AuthIgnoreConfig authIgnoreConfig;
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit;
 | 
			
		||||
public class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private RedisTemplate<Object,Object> redisTemplate;
 | 
			
		||||
    private RedisTemplate<String,Object> redisTemplate;
 | 
			
		||||
 | 
			
		||||
    @SneakyThrows
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@ import java.util.Date;
 | 
			
		||||
public class CustomLogoutSuccessHandler implements LogoutSuccessHandler {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private RedisTemplate<Object,Object> redisTemplate;
 | 
			
		||||
    private RedisTemplate<String,Object> redisTemplate;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ import java.util.concurrent.TimeUnit;
 | 
			
		||||
public class RedisLock {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private RedisTemplate<Object, Object> redisTemplate;
 | 
			
		||||
    private RedisTemplate<String, Object> redisTemplate;
 | 
			
		||||
    /*** 释放锁脚本,原子操作,lua脚本*/
 | 
			
		||||
    private static final String UNLOCK_LUA;
 | 
			
		||||
    /*** 默认过期时间(30ms)*/
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,17 @@
 | 
			
		||||
package com.suke.czx.config;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import com.suke.czx.common.utils.Constant;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.cache.annotation.EnableCaching;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
import org.springframework.context.annotation.Primary;
 | 
			
		||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
 | 
			
		||||
import org.springframework.data.redis.cache.RedisCacheManager;
 | 
			
		||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
 | 
			
		||||
import org.springframework.data.redis.core.*;
 | 
			
		||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
 | 
			
		||||
import org.springframework.data.redis.serializer.RedisSerializer;
 | 
			
		||||
import com.suke.czx.common.utils.Constant;
 | 
			
		||||
 | 
			
		||||
import java.time.Duration;
 | 
			
		||||
 | 
			
		||||
@@ -22,7 +21,6 @@ import java.time.Duration;
 | 
			
		||||
public class RedisConfig {
 | 
			
		||||
 | 
			
		||||
    @Bean
 | 
			
		||||
    @Primary
 | 
			
		||||
    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
 | 
			
		||||
        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
 | 
			
		||||
        redisTemplate.setKeySerializer(RedisSerializer.string());
 | 
			
		||||
 
 | 
			
		||||
@@ -31,10 +31,10 @@ import java.io.IOException;
 | 
			
		||||
@Slf4j
 | 
			
		||||
public class AuthenticationTokenFilter extends OncePerRequestFilter {
 | 
			
		||||
 | 
			
		||||
    private final RedisTemplate<Object,Object> redisTemplate;
 | 
			
		||||
    private final RedisTemplate<String,Object> redisTemplate;
 | 
			
		||||
    private final AuthIgnoreConfig authIgnoreConfig;
 | 
			
		||||
 | 
			
		||||
    public AuthenticationTokenFilter(AuthIgnoreConfig authIgnoreConfig,RedisTemplate<Object,Object> template) {
 | 
			
		||||
    public AuthenticationTokenFilter(AuthIgnoreConfig authIgnoreConfig,RedisTemplate<String,Object> template) {
 | 
			
		||||
        this.redisTemplate = template;
 | 
			
		||||
        this.authIgnoreConfig = authIgnoreConfig;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -22,10 +22,10 @@ import org.springframework.web.filter.OncePerRequestFilter;
 | 
			
		||||
public class ValidateCodeFilter extends OncePerRequestFilter {
 | 
			
		||||
 | 
			
		||||
    private final AntPathMatcher pathMatcher = new AntPathMatcher();
 | 
			
		||||
    private final RedisTemplate<Object,Object> redisTemplate;
 | 
			
		||||
    private final RedisTemplate<String,Object> redisTemplate;
 | 
			
		||||
    private final AuthenticationFailureHandler authenticationFailureHandler;
 | 
			
		||||
 | 
			
		||||
    public ValidateCodeFilter(RedisTemplate<Object,Object> redisTemplate, AuthenticationFailureHandler authenticationFailureHandler){
 | 
			
		||||
    public ValidateCodeFilter(RedisTemplate<String,Object> redisTemplate, AuthenticationFailureHandler authenticationFailureHandler){
 | 
			
		||||
        this.redisTemplate = redisTemplate;
 | 
			
		||||
        this.authenticationFailureHandler = authenticationFailureHandler;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit;
 | 
			
		||||
public class SysLoginController extends AbstractController {
 | 
			
		||||
 | 
			
		||||
    private final Producer producer;
 | 
			
		||||
    private final RedisTemplate<Object,Object> redisTemplate;
 | 
			
		||||
    private final RedisTemplate<String,Object> redisTemplate;
 | 
			
		||||
 | 
			
		||||
    @AuthIgnore
 | 
			
		||||
    @RequestMapping(value = "/", method = RequestMethod.GET)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user