@Bean
public ResourceConfig resourceConfig() {
ResourceConfig resourceConfig = new ResourceConfig(); // 开启gzip压缩支持请求
resourceConfig.register(GZipEncoder.class);
// 开启gzip压缩支持响应(依赖的包:org.glassfish.jersey.ext:jersey-entity-filtering:2.27)
resourceConfig.register(EntityFilteringFeature.class);
EncodingFilter.enableFor(resourceConfig, GZipEncoder.class); return resourceConfig;
}
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-entity-filtering</artifactId>
<version>2.27</version>
</dependency>