You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Shell中使用ComponentFlow如何接收非英文字符?

Spring Shell ComponentFlow无法接收非英文字符输入

正常使用Spring Shell时,非英文字符输入可正常工作,但使用ComponentFlow时无法接收这类字符,按键输入似乎被忽略。终端编码已显示为UTF-8,但问题仍存在。

相关代码

Java命令类

@ShellComponent
public class TestCommand {
    @ShellMethod(key = "test-locale")
    public String testLocale() {
        logger.info("Terminal is not null. Charset: " + terminal.encoding().displayName());

        ComponentFlow flow = componentFlowBuilder.clone()
                .withStringInput("testString").and().build();
        
        ComponentFlowResult result = flow.run();

        return "testString = " + result.getContext().get("testString");
    }
}

pom.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="https://maven.apache.org/POM/4.0.0"
    xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.3.2</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>group</groupId>
    <artifactId>artifact</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>name</name>
    <properties>
        <java.version>21</java.version>
        <spring-shell.version>3.3.1</spring-shell.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.shell</groupId>
            <artifactId>spring-shell-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.shell</groupId>
            <artifactId>spring-shell-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.shell</groupId>
                <artifactId>spring-shell-dependencies</artifactId>
                <version>${spring-shell.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <plugins>

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

内容的提问来源于stack exchange,提问作者Kasper

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 04:00:14