Spring Boot内嵌web容器启用GZIP压缩

在application.properties里启用压缩,并设置压缩支持的格式(默认支持text/html等,但不支持application/json),设置超过多少字节进行需要压缩

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