After Java application is deployed in Linux environment, Chinese is displayed as square solution

Reason: The server has no corresponding font
Solutions:
In Java environments above JRE 5, Java automatically loads the fonts under the $JAVA_HOME/ JRE /lib/ Fonts directory. Link or copy text or Microsoft yahei fonts to this directory to solve.
 
For example, if Java application is deployed in Docker container, font files need to be put into the corresponding directory when building the image, as follows
1. Create a new directory under Project Resources, TTF, and put the font file into the directory
2. Add configuration to the Maven plug-in Docker-Maven-Plugin in poM configuration
configuration.resources
< resource>
& lt; targetPath> /< /targetPath>
& lt; directory> ${project.build.outputDirectory}< /directory> < ! — Resource directory –& GT;
& lt; include> ttf/*< /include> < ! — The font file in the TTF directory that the program depends on –& GT;
< /resource> # font file

ADD the vera.ttf/* $JAVA_HOME/jre/lib/fonts/fallback/
3. DockerFile new are as follows
# font file
ADD the vera.ttf/* $JAVA_HOME/jre/lib/fonts/fallback
 
Fonts files can be downloaded from the web. The Windows environment Fonts file is located in the directory C:\Windows\ \Fonts\; you can also get the corresponding font files
 
Extension :(if the server has installed the corresponding font, the jre directory can not put the font file)
The Linux server installs fonts
01. Install font related software packages

yum install -y fontconfig mkfontscale
02, copy fonts to the specified directory
cp simsun.ttc /usr/share/fonts/
Mkfontscale // font extension
mkfontdir // new font directory
fc-cache-fv // refresh cache
03. Verify font installation
fc-list //” song style “Chinese font has been installed successfully
 

Read More: