yml配置
security:session:type: jwt
接口和实现类
public interface TokenManager {
}@ConditionalOnProperty(value = "security.session.type", havingValue = "jwt")
@Service
public class JwtTokenManager implements TokenManager {
}@ConditionalOnProperty(value = "security.session.type", havingValue = "redis-token")
@Service
public class RedisTokenManager implements TokenManager {
}
使用
@Slf4j
@Service
@RequiredArgsConstructor
public class AuthServiceImpl implements AuthService {private final TokenManager tokenManager;}