在Spring-boot-starter-parent版本2.0.1.RELEASE下立即关闭Spring Boot App

时间:2018-04-16 13:58:14

标签: java spring spring-boot

我正在研究JavaBrain的春季启动视频,我遇到了与下面链接相同的错误。

Why does my Spring Boot App always shutdown immediately after starting?

我已经指定了spring-boot-starter-web的依赖关系,但仍然遇到了错误。我的pom.xml看起来像这样。问题是我将spring-boot-starter-parent的版本更改为1.4.2.RELEASE一切正常(我可以访问localhost:8080)。我想知道为什么会发生这种情况,我该怎样做才能使2.0.1.RELEASE工作。

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
  </parent>

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

代码如下所示:

@SpringBootApplication
public class CourseApiApp {

    public static void main(String[] args) {
        SpringApplication.run(CourseApiApp.class, args);

    }

}

输出:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.1.RELEASE)

2018-04-16 21:42:07.576  INFO 8976 --- [           main] org.kouchibin.web.CourseApiApp           : Starting CourseApiApp on SAI with PID 8976 (C:\Users\86660\Documents\workspace-sts\course-api\target\classes started by kcb in C:\Users\86660\Documents\workspace-sts\course-api)
2018-04-16 21:42:07.583  INFO 8976 --- [           main] org.kouchibin.web.CourseApiApp           : No active profile set, falling back to default profiles: default
2018-04-16 21:42:07.670  INFO 8976 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4c40b76e: startup date [Mon Apr 16 21:42:07 CST 2018]; root of context hierarchy
2018-04-16 21:42:08.971  INFO 8976 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-04-16 21:42:08.990  INFO 8976 --- [           main] org.kouchibin.web.CourseApiApp           : Started CourseApiApp in 1.976 seconds (JVM running for 2.624)
2018-04-16 21:42:08.997  INFO 8976 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@4c40b76e: startup date [Mon Apr 16 21:42:07 CST 2018]; root of context hierarchy
2018-04-16 21:42:09.000  INFO 8976 --- [       Thread-2] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

1 个答案:

答案 0 :(得分:1)

我已经解决了这个问题。当我手动使用mvn compile时,不是单击eclipse中的RUN按钮,而是显示了更多细节,其中一些依赖项无法解析。所以我在本地存储库中检查了这些依赖项。问题是某些依赖项未完全下载(使用&#34; .inprogress&#34;后缀)。所以解决这个问题的方法是删除所有那些破坏的依赖项并重新编译应用程序,这将再次下载依赖项。我想这个问题最有可能发生在中国,由于防火墙的缘故,与maven存储库的连接不稳定。 1.4.2.RELEASE工作的原因很简单,因为所有依赖项都是偶然成功下载的。