使用application.properties配置文件造成的漢字亂碼問題解決

在使用配置文件爲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的編碼爲uft-8的方式,我們把編碼方式修改一下就可以了,找到file->Settings,在其中輸入“File Encoding”,找到位置,把Properties Files的文件編碼設置,與下圖中紅框一致。

重新編譯項目,執行結果如下。能夠正常識別漢字。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章