springboot内置tomcat启动服务出现异常提示中文乱码,保存数据json解析异常等问题,折腾了半天,原来用cmd窗口直接启动跟放bat里执行效果是不一样的:
# Tomcat
server:
port: 8089
tomcat:
uri-encoding: UTF-8
spring:
http:
encoding:
force: true
charset: UTF-8
enabled: true
发现java代码里没有写produces = {“application/json; charset=utf-8”})
@PostMapping(value = "/add", produces = {"application/json; charset=utf-8"})

400 BAD_REQUEST "Failed to read HTTP message"; nested exception is org.springframework.core.codec.DecodingException: JSON decoding error: Invalid UTF-8 start byte 0xb6; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Invalid UTF-8 start byte 0xb6 at [Source: (io.netty.buffer.ByteBufInputStream); line: 1, column: 54] (through reference chain: com.evn.gateway.entity.GatewayRoute["serviceName"])

启动命令(java -Dfile.encoding=UTF-8 -jar -Xms128m -Xmx256m XXX.jar)
在双击执行bat启动生效 ,提示正常了,提交数据也能成功。
