当我使用 IDE 或命令行中的 mvn spring-boot:run
命令来启动我的应用程序时,它工作正常,但是当我尝试使用 mvn spring-boot:start
时code> 它会启动服务器,然后立即关闭它。
这是修剪后的日志(注意:构建成功后关闭)
2019-04-30 23:05:32.700 INFO 23764 --- [lication.main()] com.Application : Started Application in 30.875 seconds (JVM running for 36.058)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35.027 s
[INFO] Finished at: 2019-04-30T23:05:32+00:00
[INFO] Final Memory: 124M/1714M
[INFO] ------------------------------------------------------------------------
2019-04-30 23:05:33.203 INFO 23764 --- [ Thread-13] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4ea8f6f3: startup date [Tue Apr 30 23:05:02 UTC 2019]; root of conte
xt hierarchy
我的 pom.xml 看起来拥有它需要的一切。它还包含 spring-boot-maven-plugin
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.4.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
我在他们的文档中找不到任何可以帮助我解决此问题的内容。
最佳答案
有关运行和启动的信息,请参阅 Spring Boot 指南
基本上,“start”被设计为更多地作为脚本运行,并在到达代码末尾时自行终止,而“run”将程序作为应用程序启动,在到达结束时不会终止代码中的点。
希望能有一点帮助。
关于java - Spring引导maven插件: spring-boot:start shuts down the web app immediately (using jetty),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55929805/