1

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 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.
0

Try to move your definition into src/main/resources/messages_zh_CN.properties. (messages_zh_CN.properties is utf8)

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.