所以我只是在我的 IDE 中设置了一个 Jline3 项目来尝试它是否有效。
它只有一个类,我从这里复制:https://github.com/jline/jline3/blob/master/builtins/src/test/java/org/jline/example/Example.java
Jline3 提供了一些我真正想要使用的不错的功能,尽管文档很差。问题是;它不适用于 Windows。它可以在 mac 终端、centos 甚至 Windows (mingw) 上的 git bash 中完美运行。
但是,如果我在 Windows 终端或 cmder 中执行我的 jar,它会发出警告,并且所有完成程序都不会工作。
WARNING: unable to create a system terminal, creating dumb terminal (enable debug logging for more information)
我的 pom 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jline3Test</groupId>
<artifactId>jline3-test</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<excludes>META_INF/*.SF</excludes>
<excludes>META_INF/*.DSA</excludes>
<excludes>META_INF/*.RSA</excludes>
</excludes>
</filter>
</filters>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>Application</mainClass>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
<version>3.8.0</version>
</dependency>
</dependencies>
问题:
有谁知道如何启用调试日志并将日志重定向到 system.out?
有没有人遇到同样的问题并且知道如何解决?
提前致谢
最佳答案
您需要在类路径中包含 jna ( https://mvnrepository.com/artifact/net.java.dev.jna/jna ) 或 jansi ( https://mvnrepository.com/artifact/org.fusesource.jansi/jansi )。
您需要 jline-terminal-jansi ( https://mvnrepository.com/artifact/org.jline/jline-terminal-jansi ) 或 jline-terminal-jna ( https://mvnrepository.com/artifact/org.jline/jline-terminal-jna ),将它们与 JLine3 集成。
因此您可以选择是使用 jansi 还是 jna,但是您必须拥有相应的 2 个库。希望对您有所帮助。
也可以直接在 Jline3 文档中找到它:https://github.com/jline/jline3#jansi-vs-jna
最好的, 标记
关于java - Windows 终端的 Jline3 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52851232/