在类路径中具有“spring-boot-starter-test”依赖项时无法启动tomcat服务器

时间:2018-04-19 09:26:54

标签: spring-boot spring-boot-starter

我的春季启动Web应用程序在启动时立即停止,没有任何错误消息:

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

当我删除spring-boot-starter-test依赖项时,问题就消失了。这是我的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>

我不知道这里发生了什么......

----- ------更新

将春季启动版本更改为1.5.x解决了这个问题。这是春季启动2.0.1的错误吗?

---------更新-------

似乎有些东西会阻止日志从打印到控制台。

2 个答案:

答案 0 :(得分:2)

正如所建议的那样,我将此作为答案发布,尽管我认为这更像是一种解决方法。我遇到了完全相同的问题,并且能够进一步缩小范围。它似乎与spring-boot-starter-test中的spring-core依赖性有关。如果我使用以下它也可以:

memcpy(memory_conf + 1, process_numbers, sizeof(process_numbers));

答案 1 :(得分:0)

我也面临类似的问题。就我而言,我从运行时中排除了通用日志记录。我在build.gradle文件中添加了以下配置。

configurations {
    runtime.exclude group: 'commons-logging', module: 'commons-logging'       
}