在springboot的application.yml文件中有中文时,读取出来的是乱码,需要进行一下操作:
将idea的配置编码设置为UTF-8,步骤如下:
- 1.Files->Editor->File Encodings,设置Global Encoding,Project Encoding和Default Encoding for Properties files编码为UTF-8
- 2.修改application.yml配置如下:
server:
port: 8081
tomcat:
uri-encoding: UTF-8
spring:
http:
encoding:
charset: utf-8
enabled: true
force: true
messages:
encoding: UTF-8
然后在应用就ok了。
- 作者:gnail_oug
- 链接:https://blog.csdn.net/gnail_oug/article/details/80111787
- 來源:CSDN