In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the springboot jar deployment console log garbled how to do, the article is very detailed, has a certain reference value, interested friends must read it!
Description of garbled Log in spring boot jar deployment console
Spring boot jar package deployment, running .jar files through the java-jar command
In the code, the Chinese and garbled code is output to the console through the variable log, but it is garbled only when running jar; when using eclipse debug, it is normal
The Chinese output in the code through System.out.println () is normal, regardless of whether it is run through jar or not
The log uses the default logback, not log4j
Solve
1. Create a new logback.xml for the resources folder (the file name cannot be modified)
The contents are as follows:
% d {yyyy-MM-dd HH:mm:ss.SSS} [% thread]%-5level% logger {50} -% msg%n
2. First of all, spring boot uses logback by default
The log configuration file named logback.xml under resources/ is read by default. If there is any, it is read. If not, the default is used.
3. Secondly, logback.xml, will
UTF-8 comment out or delete
4. If logback.xml is not configured
Use the default configuration, then deploy the jar package, java-jar xxx.jar, and the output Chinese of the log variable in the code, garbled; if logback.xml is configured, but charset uses UTF-8, then the Chinese is still garbled; only by using logback.xml and deleting charset, can you ensure that the Chinese is normal.
5. Aiming at this very specific problem
I have tried, and useless, to add-Dfile.encoding=UTF-8 under the plugin- > spring-boot-maven-plugin- > configuration node of pom, or to add the parameter-Dfile.encoding=UTF-8 when running the .jar package, which is still useless.
After springboot is packaged, run Chinese garbled code in the Windows console.
After springboot is packaged, if you run it directly in the Windows console through java-jar, there will be garbled codes in Chinese, and the garbled codes stored in the database will also be garbled. There will be no garbled codes by running directly in idea.
In order to solve the problem of garbled code in the Windows console, add the-Dfile.encoding=utf-8 run parameter in the running script
For example, java-jar-Dfile.encoding=utf-8 app-0.0.1-SNAPSHOT.jar is all the contents of the article "what to do about the jar deployment console log garbled in springboot". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.