2017-06-01 69 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

回答