在使用配置文件为Spring Boot对象注入值的时候出现乱码。

配置文件如下,“你猜呢”出现乱码

student.name=你猜呢
student.isfemale=true
student.birth=2014/4/1
student.teachers=Zhang, Liu
student.grade.English=89
student.grade.Math=100
student.pets.age=2
student.pets.spices=dog

使用application.properties配置文件造成的汉字乱码问题解决

这是因为application.properties的编码为uft-8的方式,我们把编码方式修改一下就可以了,找到file->Settings,在其中输入“File Encoding”,找到位置,把Properties Files的文件编码设置,与下图中红框一致。

使用application.properties配置文件造成的汉字乱码问题解决

重新编译项目,执行结果如下。能够正常识别汉字。

使用application.properties配置文件造成的汉字乱码问题解决

相关文章:

  • 2022-12-23
  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-05
  • 2022-12-23
  • 2021-12-26
  • 2021-07-22
  • 2021-08-14
  • 2021-12-06
  • 2022-12-23
相关资源
相似解决方案