Search code examples
spring-bootspring-boot-starter

Cannot start tomcat server when having "spring-boot-starter-test" dependency in classpath


My spring boot web application stopped immediately without any error message when starting:

:: Spring Boot ::        (v2.0.1.RELEASE)

2018-04-19 17:15:34.009  INFO 5600 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-04-19 17:15:34.013  INFO 5600 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.29
2018-04-19 17:15:34.027  INFO 5600 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/whf/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2018-04-19 17:15:34.129  INFO 5600 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-04-19 17:15:34.514  INFO 5600 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

When I removed the spring-boot-starter-test dependency the problem went away. Here is my pom.xml:

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>2.0.1.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

        <dependency>
            <groupId>org.hyperledger.fabric-sdk-java</groupId>
            <artifactId>fabric-sdk-java</artifactId>
            <version>1.1.0-alpha</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
        </dependency>

        <!-- remove this dependency can fix this problem -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

I have no idea what's going on here....

-----update------

Changing spring boot version to 1.5.x solved the problem. Is it a bug of spring boot 2.0.1?

---------update-------

It seems that something stops the logs from printing to console.


Solution

  • As suggested, I'm posting this as an answer, even though I consider it more of a workaround. I was running into exactly the same issue and was able to narrow it down a tiny bit further. It seems to be related to the spring-core dependency within spring-boot-starter-test. If I use the following it also works:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>