I use @ConfigurationProperties to customize my own properties in application.properties. But when I use chinese in application.properties, I found out Spring Boot load application.properties file in ISO-8859-1 encode. How do I customize this defalut encoding using UTF-8.
2 Answers
JAVA hold all string in memory with unicode instead of its own encoding. So the importance is to tell java how to load string in correct encoding. Most common solution (i18n use this way) is to translate chinese into unicode, which java can handle it directly.
Here is an online tool to translate chinese to unicode. Hope this helps.
1 Comment
ArenaGod
Thanks for your answer. I really solve it by replace chinese to unicode. But I am still thinking could I set the encoding of loading application.properties in Spring Boot. There should be a way. I look up Spring Boot and find
SpringApplication has a method to set ResourceLoader, but I don't know if it will work. I'll try it.Try to move your definition into src/main/resources/messages_zh_CN.properties. (messages_zh_CN.properties is utf8)
1 Comment
ArenaGod
Thank you. I have considered this method, but application.properties is not for i18n. It's just chinese appears in config properties file. So changing file name including zh_CN seems like not the best way.