Spring Boot: How do I load application.properties files with UTF-8 - utf-8

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.

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.

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

Related

Trademark Symbol changed to ? on SpringBoot: Debian

I have services developed using Spring Boot 2.2.4 which takes POST parameters as input. The problem is that if I input a string having any special symbols i.e. Copyright symbol or Trademark symbol it works fine with Windows system but when deployed on k8s, it changes to '?' symbol. I tried setting the #Consumes with charset UTF-8, setting the spring properties:
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled= true
spring.http.encoding.force= true
Still the problem persists. I am not sure if this is an encoding problem or some other configuration problem with Linux/ SpringBoot.

Custome attributes that contains Chinese in Spring Boot

I add some custom attributes which contains Chinese in a Spring Boot project. However, the attributes show the wrong way.
I use the idea and set file encoding with utf-8.
Oh, and I am using YAML instead of Properties
What should I do?
oh, there is no problem.I use the Properties file before, and change to YAML.
So, it shows wrong situation.
I solve the problem by cleaning the project and restarting it.

Arborescent structure in application.properties

I am reading/practicing a security management tutorial with Spring-boot. I noticed that I could customize the application by using either a file named application.properties or a file named application.ymldepending on the syntax I prefer.
Then I reached a point in the tutorial where it is asked to put this piece of information in application.yml :
security:
sessions: NEVER
Problem : this piece of configuration is obviously arborescent and fits well in application.yml but what would be the equivalent in application.properties which, AFAIK, like every .properties files is not meant to store arborescent data?
Where YAML uses new lines and indentation, a properties file uses . separators. The equivalent configuration in application.properties would be:
security.sessions=NEVER

How to Convert Java Web Application into Gujarati Language

I want to convert my web application into Gujarati language.In my web application i use Spring and Hibernate framework.how can i do this ? Please give me solution.
One solution can be using ReloadableResourceBundleMessagesource.
As for example, if you want the site in two different languages, say english and german, then create two different properties file, messages_de and messages_en.
Use a LocaleResolver to resolve the Locale and LocaleChangeInterceptor to intercept the request and set the lang value.
Follow this simple example :
http://viralpatel.net/blogs/spring-3-mvc-internationalization-i18n-localization-tutorial-example/
I will look into the possibilities of using some translation API and let you know if I get something.

Getting MongoDB + Spring MVC to speak UTF8

I have an application that is based on mongodb + spring and a RESTful interface (via Spring MVC).
When we send a request to the server to make an update (e.g. a user field), and the field has non-ascii character (e.g. Cyrillic / Russian) it is saved to mongo but when we read it back through the interface we get garbled chars.
Any ideas on how to tackle this issue?
Thanks!
We have found out that the issue was with how JSoup treats non-ascii chars. Now it works.

Resources