简体   繁体   中英

Spring boot maven plugin: spring-boot:start shuts down the web app immediately (using jetty)

When I use IDE or mvn spring-boot:run command from command line to bring up my app it works fine but when I try to use mvn spring-boot:start it brings up the server and then closes it immediately. Here is the trimmed log (Note: the closing after build success)

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

My pom.xml looks like has everything it needs. It also contains 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>

I could not find anything in their documentation that could help me with this issue.

Refer to spring boots guides on run and start

spring-boot:start

spring-boot:run

basically put, "start" is designed to run more as a script and terminates itself when it reaches the end of the code, where as "run" starts the program as an application which doesn't terminate when it reaches an end point in the code.

hope that helps a little.

Turns out the issue was with the version of the spring boot maven plugin I was running. Once I moved to the new release version I no longer see this issue.

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.4.RELEASE</version>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM