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
相关产品推荐
相关产品推荐

