简体   繁体   中英

maven does not show colors in spring

I am trying to display colors when I execute test but it does not work for spring 2

i tried

spring.output.ansi.enabled=always

still same result.

i tried this website:

Enable Color in Spring Boot Test Console Log

but get only "black and white", the colors never shows up

I have maven 3.5.2 and spring/boot 2

unitest result: 在此处输入图像描述 springboot tests result: 在此处输入图像描述

What is your pom.xml configuration. Depending on which group/artifact you are using to run the mvn verify .

I am using the org.codehaus.mojo and I was never able to make it work, I switched to org.springframework.boot/spring-boot-maven-plugin and it worked for me.

Try this configuration and try again:

<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>

EDIT: In addition, make sure you have:

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

As it might be because of case sensitivity so change always to uppercase like below.

spring.output.ansi.enabled=ALWAYS

Yes, you do need to use spring.output.ansi.enabled=ALWAYS (in my testing the value is case-insensitive, supporting ALWAYS or always ).

The key for colored output for Spring Boot tests is to place this value in your test resource folder: src/test/resources/application.properties .

If you only place that property in the src/main/... folder, it won't apply to your tests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM