错误:包 io.jsonwebtoken.impl.compression 不存在

问题描述 投票:0回答:1

当我将

jsonwebtoken
依赖项升级到版本
0.12.5
时,我开始收到以下错误 知道如何解决这个问题吗?

错误:

package io.jsonwebtoken.impl.compression does not exist

这是我的 Maven 依赖项:

 <dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-api</artifactId>
    <version>0.12.5</version>
</dependency>
<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-impl</artifactId>
    <version>0.12.5</version>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-jackson</artifactId>
    <version>0.12.5</version>
    <scope>runtime</scope>
</dependency>

Java 导入:

import io.jsonwebtoken.impl.compression.GzipCompressionCodec;
spring spring-boot maven jwt
1个回答
0
投票

'io.jsonwebtoken:jjwt-impl:0.12.0'
开始,Gzip压缩编解码器已被删除。

相反,引入了类似的类 GzipCompressionAlgorithm

您可以在以下链接找到更多详细信息。

* Removed all usages of CompressionCodecs.java in favor of a new Jwts.ZIP entry.
Renamed all Standard***AlgorithmsBridge to Standard***Algorithms

https://github.com/jwtk/jjwt/commit/529f04dd9097331220c3239bdadacee6b1dfd6de

/*
 * Copyright (C) 2015 jsonwebtoken.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.jsonwebtoken.impl.compression;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;

/**
 * Codec implementing the <a href="https://en.wikipedia.org/wiki/Gzip">gzip compression algorithm</a>.
 *
 * @since 0.6.0
 */
public class GzipCompressionAlgorithm extends AbstractCompressionAlgorithm {

    private static final String ID = "GZIP";

    public GzipCompressionAlgorithm() {
        super(ID);
    }

    @Override
    protected OutputStream doCompress(OutputStream out) throws IOException {
        return new GZIPOutputStream(out);
    }

    @Override
    protected InputStream doDecompress(InputStream is) throws IOException {
        return new GZIPInputStream(is);
    }
}

如果您想使用GzipCompressionCodec,您需要使用0.11.5或更早版本的io.jsonwebtoken。

<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-impl -->
<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-impl</artifactId>
    <version>0.11.5</version>
    <scope>runtime</scope>
</dependency>
© www.soinside.com 2019 - 2024. All rights reserved.