3

我的 Spring Boot 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>

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

- - -更新 - - -

更改 spring boot 版本以1.5.x解决问题。它是spring boot 2.0.1的错误吗?

- - - - -更新 - - - -

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

4

2 回答 2

2

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

<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>
于 2018-05-03T14:04:20.130 回答
0

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

configurations {
    runtime.exclude group: 'commons-logging', module: 'commons-logging'       
}
于 2019-06-13T15:13:09.850 回答