我在执行测试时试图显示颜色,但不适用于春季2

我试过了

spring.output.ansi.enabled=always


还是一样的结果。

我试过这个网站:

Enable Color in Spring Boot Test Console Log

但只得到“黑白”,颜色永远不会显示

我有Maven 3.5.2和spring / boot 2

单项结果:
java - Maven在 Spring 不显示颜色-LMLPHP
springboot测试结果:
java - Maven在 Spring 不显示颜色-LMLPHP

最佳答案

您的pom.xml配置是什么。根据您用于运行mvn verify的组/工件。

我正在使用org.codehaus.mojo,但我无法使其正常工作,因此我切换到org.springframework.boot / spring-boot-maven-plugin,它对我有用。

请尝试此配置,然后重试:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>pre-integration-test</id>
            <goals>
                <goal>start</goal>
            </goals>
        </execution>
        <execution>
            <id>post-integration-test</id>
            <goals>
                <goal>stop</goal>
            </goals>
        </execution>
    </executions>
</plugin>


编辑:
此外,请确保您具有:

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

09-10 03:34
查看更多