2017-06-01 71 views
0

我有一个弹簧引导应用程序,它产生了一个巨大的JSON响应,它的差不多是2MB。我尝试在application.properties文件中添加以下内容,但尝试过在线可用的解决方案,但它无法工作,有人可以帮忙吗?Spring引导请求响应压缩

server.compression.enabled=true 
server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain 

这是方法的签名,如果有帮助, 我使用的弹簧引导版本1.3.3和测试与邮递员的服务。

@RequestMapping(value="/getAssetsSMC",method=RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) 
     public @ResponseBody String getAssetsSMC(@RequestParam(value = "accessKey", required = true) String accessKey) throws IOException 
{ 
    // code 
return gson.toJson(products); 
} 
+0

您是使用嵌入式服务器还是构建战争并部署它?你正在使用哪种Spring Boot版本。你如何测试压缩? –

+0

我使用的是嵌入式tomcat,只有建立jar。使用弹簧启动版本1.3.3和通过邮差测试压缩 – Bhargav

回答