Repository navigation
Conversation
Java 17 及更早版本在中文 Windows 上按 GBK 读取文本,Spring 应用解析 UTF-8 的 YAML 配置时抛出 MalformedInputException 而无法启动,控制台 中文也是乱码;IntelliJ IDEA 启动时会固定 UTF-8,所以同一项目在 IDEA 里正常。 每次运行、调试和测试启动都在参数最前面加入 -Dfile.encoding=UTF-8、 -Dsun.stdout.encoding=UTF-8 和 -Dsun.stderr.encoding=UTF-8,启动参数里 已经设置的属性不再重复添加。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue / Linked issue
无对应 Issue。问题在 Lithe 0.8.1 + Java Support 2.0.1 上复现,详见下文。
类型 / Type
fix:缺陷修复
背景 / Why
在中文 Windows 上用 Java Support 运行或调试 Spring Boot 应用(Java 17)时,应用启动失败:
控制台中文 banner 和日志也是乱码。同一项目在 IntelliJ IDEA 中正常启动。
根因:Java 18 之前,JVM 用平台字符集读取文本,中文 Windows 上是 GBK。插件启动 JVM 时没有指定编码,Spring 从配置中心拉到的 UTF-8 YAML 被按 GBK 解析失败,配置缺失导致启动失败。IntelliJ IDEA 在启动时会固定
-Dfile.encoding=UTF-8,所以那边正常。Lithe 的运行窗口按 UTF-8 解码进程输出,控制台流也需要固定 UTF-8。改动 / Changes
backend/src/run.rswith_utf8_encoding:在每次运行、调试和测试启动的参数最前面加入-Dfile.encoding=UTF-8、-Dsun.stdout.encoding=UTF-8、-Dsun.stderr.encoding=UTF-8。start中对主类和测试两种启动统一应用;调试时 JDWP agent 仍排在最前。验证 / Verification
cargo test -p lithe-java-backend --lib run::lithe-java-backend,替换本机 2.0.1 插件后端未能执行:端到端验证(用修复后的后端启动 Spring Boot 应用、确认不再出现
MalformedInputException)还没有完成,完成后在本 PR 补充结果。macOS / Linux 未运行。🤖 Generated with Claude Code