压缩在 spring 中不起作用,但它在响应 headers 中将 Content-Encoding 显示为 gzip

Compression is not working in spring but, it is showing Content-Encoding as gzip in the response headers

我正在尝试压缩来自 java spring-boot 应用程序的响应。我参考了一些教程和 Whosebug 问题,发现我只需要添加这些行

server.compression.enabled=true
server.compression.min-response-size=1
server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json

application.properties 文件中,所以我继续添加了那些,但是在添加这些行之后,我得到了 Content-Encoding as gzip 但是响应的大小和以前一样,我也 double-checked 通过删除它们来改变大小,唯一改变的是是 Content-Encoding 类型并且大小没有受到影响。我正在为发送模型

的 API 使用嵌入式 tomcat 服务器
public class UpdateUserResponseModel {
    
    private String userId;

    private String email;

    private int age;

    private long aadhaar;

    private String streetName;
    
    private String city;

    private String Country; 

    private boolean citizenCheck;

    public String getUserId() {
        return this.userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getAge() {
        return this.age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public long getAadhaar() {
        return this.aadhaar;
    }

    public void setAadhaar(long aadhaar) {
        this.aadhaar = aadhaar;
    }

    public String getStreetName() {
        return this.streetName;
    }

    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }

    public String getCity() {
        return this.city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCountry() {
        return this.Country;
    }

    public void setCountry(String Country) {
        this.Country = Country;
    }

    public boolean isCitizenCheck() {
        return this.citizenCheck;
    }

    public boolean getCitizenCheck() {
        return this.citizenCheck;
    }

    public void setCitizenCheck(boolean citizenCheck) {
        this.citizenCheck = citizenCheck;
    }

}


我的 spring-boot 版本是 2.4.5 我在这里遗漏了什么吗?

这可能是我们使用邮递员进行测试时的问题,正如 here 所要求的那样,因此为了验证,我尝试使用 chrome 并获得了压缩大小(通过网络传输)以及显示为(资源大小)的实际大小,以及 header“Content-Encoding”作为“gzip”。