SpringBoot yml文件自定义属性乱码

在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了。


 上一篇
spring boot项目打包成war并在tomcat上运行的步骤 spring boot项目打包成war并在tomcat上运行的步骤
一、修改打包形式在pom.xml里设置 <packaging>war</packaging> 二、移除嵌入式tomcat插件在pom.xml里找到spring-boot-starter-web依赖节点,在其中添加如下代码,
2019-11-25
下一篇 
hexo打包报TypeError Cannot read property 'count' of undefined hexo打包报TypeError Cannot read property 'count' of undefined
某一天,突然想将自己的博客文章发布打包项目时,报如下错误: $ hexo g INFO Start processing FATAL Something's wrong. Maybe you can find the solution he
2019-11-24
  目录