ApplicationPidFileWriter does not create .pid file in Spring Boot

The following setting does not create a .pid file (as described here - http://www.kubrynski.com/2014/05/managing-spring-boot-application.html :

public static void main(String[] args) {
        SpringApplication app = new SpringApplication(BrokerFeedApplication.class);
        app.addListeners(new ApplicationPidFileWriter());
        app.run(BrokerFeedApplication.class, args);
    }

      

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.5.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

      

What am I missing?

+3


source to share


1 answer


By using the method static run(Object source, String... args)

on the last line, you are not taking into account the configuration app

you did on the first two lines, See the Javadoc (main focus):

A static helper that can be used to run SpringApplication from a specified source using default settings.

Change the last line to use an instance method run(java.lang.String...)

to use the previously registered listener, i.e. edit:



app.run(DemoApplication.class, args);

      

to

app.run(args);

      

+4


source







All Articles