Original link: http://www.zslin.com/web/article/detail/47
Problem Description
When there is Chinese in the configuration file of. Properties, the reads are always garbled. For example, the contents of my application.properties configuration file are as follows:
server.port=9090
test.msg= Hello: springboot
When reading the test.msg value in the program will always get garbled, the default is to read in iso-8859-1 character encoding, the method to try is:
1. Add Configuration
Banner.charset=utf-8
server.tomcat.uri-encoding=utf-8
spring.http.encoding.charset=utf-8
Spring.http.encoding.enabled=true
spring.http.encoding.force=true
spring.messages.encoding=utf-8
2. Set File type
Modify the Application.properites file type to the UTF-8 encoding type.
The above method tests to obtain the value or garbled. • Solutions
To set the transparent NATIVE-TO-ASCII conversion for File encodings to true, follow these steps: click
File-> Settings-> Editor-> file encodings
Set the default encoding for properties files under Properties Files (*.properties) to UTF-8 to Transparent NATIVE-TO-ASCII Conversion before the check on the selection.
This is one of the most common solutions on the Web, but when you develop under Eclipse, you will find that the corresponding transparent NATIVE-TO-ASCII conversion settings option is not found at all.
So how do you solve the problem of Chinese garbled in the Spring boot read configuration file under Eclipse?
First of all, the analysis of the role of transparent NATIVE-TO-ASCII conversion settings, Chinese translation is transparent native-to-ascii conversion.
Analysis is that the property files in Eclipse are converted to ASCII code to be parsed.
Baidu Search, eclipse how to set the properties file transparent Native-to-ascii conversion
Get: Install properties plugin propertieseditor and settings in Eclipse (drawings), ASCII code to Chinese
Http://www.cnblogs.com/zdz8207/p/java-eclipse-properties.html
It is recommended to use offline installation inside.
After the installation completes the Propertieseditor plug-in, use the editor to edit the Chinese in the property file again, and then rerun the program.
Found that the read Chinese configuration file is not garbled.