Springboot shutdown automatically and restart automatically .











up vote
0
down vote

favorite












I encounter a problem that my springboot project will shutdown and restart automatically.
Before that problem, the program finish schedule job, this scheduling job will read data from redis and then compare with local backup file, if any new data coming up, the program will write to local backup file.
The following part is the shutdown log
console log










share|improve this question


















  • 1




    Are you using spring-boot-devtools dependency in your pom.xml file?
    – Hrudayanath
    Nov 13 at 2:04








  • 1




    Yes, and thank you for your answering, I already solved this problem by Set the System.setProperty("spring.devtools.restart.enabled", "false");
    – JunHui Li
    Nov 15 at 2:05















up vote
0
down vote

favorite












I encounter a problem that my springboot project will shutdown and restart automatically.
Before that problem, the program finish schedule job, this scheduling job will read data from redis and then compare with local backup file, if any new data coming up, the program will write to local backup file.
The following part is the shutdown log
console log










share|improve this question


















  • 1




    Are you using spring-boot-devtools dependency in your pom.xml file?
    – Hrudayanath
    Nov 13 at 2:04








  • 1




    Yes, and thank you for your answering, I already solved this problem by Set the System.setProperty("spring.devtools.restart.enabled", "false");
    – JunHui Li
    Nov 15 at 2:05













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I encounter a problem that my springboot project will shutdown and restart automatically.
Before that problem, the program finish schedule job, this scheduling job will read data from redis and then compare with local backup file, if any new data coming up, the program will write to local backup file.
The following part is the shutdown log
console log










share|improve this question













I encounter a problem that my springboot project will shutdown and restart automatically.
Before that problem, the program finish schedule job, this scheduling job will read data from redis and then compare with local backup file, if any new data coming up, the program will write to local backup file.
The following part is the shutdown log
console log







java spring tomcat web






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 at 1:57









JunHui Li

6




6








  • 1




    Are you using spring-boot-devtools dependency in your pom.xml file?
    – Hrudayanath
    Nov 13 at 2:04








  • 1




    Yes, and thank you for your answering, I already solved this problem by Set the System.setProperty("spring.devtools.restart.enabled", "false");
    – JunHui Li
    Nov 15 at 2:05














  • 1




    Are you using spring-boot-devtools dependency in your pom.xml file?
    – Hrudayanath
    Nov 13 at 2:04








  • 1




    Yes, and thank you for your answering, I already solved this problem by Set the System.setProperty("spring.devtools.restart.enabled", "false");
    – JunHui Li
    Nov 15 at 2:05








1




1




Are you using spring-boot-devtools dependency in your pom.xml file?
– Hrudayanath
Nov 13 at 2:04






Are you using spring-boot-devtools dependency in your pom.xml file?
– Hrudayanath
Nov 13 at 2:04






1




1




Yes, and thank you for your answering, I already solved this problem by Set the System.setProperty("spring.devtools.restart.enabled", "false");
– JunHui Li
Nov 15 at 2:05




Yes, and thank you for your answering, I already solved this problem by Set the System.setProperty("spring.devtools.restart.enabled", "false");
– JunHui Li
Nov 15 at 2:05












2 Answers
2






active

oldest

votes

















up vote
3
down vote













Incase if you are using spring-boot-devtools dependency in your pom.xml file, when any new changes are made to existing project it will automatically restart the project. It helps in cases where on making minor changes, the project is automatically restarted and the application start time is also significantly small compared to normal scenario. If you don't wish to have this behavior you can just remove the following dependency from you pom.xml file, thereby there is no automatic restart of application.



<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>





share|improve this answer























  • Please provide the scope as runtime : <scope>runtime</scope>
    – Lova Chittumuri
    Nov 13 at 4:05










  • Thanks, I already solved this problem. it might be the same as your solution:
    – JunHui Li
    Nov 15 at 2:05


















up vote
0
down vote













You can add the Shutdown hook in my application.



Java shutdown hook runs in these two cases.




  • The program exits normally, or we call System.exit() method to terminate the program. Read more about Java System Class.

  • User interrupts such as Ctrl+C, system shutdown etc.


Code:



Runtime.getRuntime().addShutdownHook(new Thread("Shutdownhook") {
public void run() {
//code here
//compare redis cache
//syn data and save local file.
try {
mainThread.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
instance.logger.error(e.getMessage(), e);
}
}
});





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53272685%2fspringboot-shutdown-automatically-and-restart-automatically%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote













    Incase if you are using spring-boot-devtools dependency in your pom.xml file, when any new changes are made to existing project it will automatically restart the project. It helps in cases where on making minor changes, the project is automatically restarted and the application start time is also significantly small compared to normal scenario. If you don't wish to have this behavior you can just remove the following dependency from you pom.xml file, thereby there is no automatic restart of application.



    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
    </dependency>





    share|improve this answer























    • Please provide the scope as runtime : <scope>runtime</scope>
      – Lova Chittumuri
      Nov 13 at 4:05










    • Thanks, I already solved this problem. it might be the same as your solution:
      – JunHui Li
      Nov 15 at 2:05















    up vote
    3
    down vote













    Incase if you are using spring-boot-devtools dependency in your pom.xml file, when any new changes are made to existing project it will automatically restart the project. It helps in cases where on making minor changes, the project is automatically restarted and the application start time is also significantly small compared to normal scenario. If you don't wish to have this behavior you can just remove the following dependency from you pom.xml file, thereby there is no automatic restart of application.



    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
    </dependency>





    share|improve this answer























    • Please provide the scope as runtime : <scope>runtime</scope>
      – Lova Chittumuri
      Nov 13 at 4:05










    • Thanks, I already solved this problem. it might be the same as your solution:
      – JunHui Li
      Nov 15 at 2:05













    up vote
    3
    down vote










    up vote
    3
    down vote









    Incase if you are using spring-boot-devtools dependency in your pom.xml file, when any new changes are made to existing project it will automatically restart the project. It helps in cases where on making minor changes, the project is automatically restarted and the application start time is also significantly small compared to normal scenario. If you don't wish to have this behavior you can just remove the following dependency from you pom.xml file, thereby there is no automatic restart of application.



    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
    </dependency>





    share|improve this answer














    Incase if you are using spring-boot-devtools dependency in your pom.xml file, when any new changes are made to existing project it will automatically restart the project. It helps in cases where on making minor changes, the project is automatically restarted and the application start time is also significantly small compared to normal scenario. If you don't wish to have this behavior you can just remove the following dependency from you pom.xml file, thereby there is no automatic restart of application.



    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
    </dependency>






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 13 at 2:37

























    answered Nov 13 at 2:15









    Hrudayanath

    1239




    1239












    • Please provide the scope as runtime : <scope>runtime</scope>
      – Lova Chittumuri
      Nov 13 at 4:05










    • Thanks, I already solved this problem. it might be the same as your solution:
      – JunHui Li
      Nov 15 at 2:05


















    • Please provide the scope as runtime : <scope>runtime</scope>
      – Lova Chittumuri
      Nov 13 at 4:05










    • Thanks, I already solved this problem. it might be the same as your solution:
      – JunHui Li
      Nov 15 at 2:05
















    Please provide the scope as runtime : <scope>runtime</scope>
    – Lova Chittumuri
    Nov 13 at 4:05




    Please provide the scope as runtime : <scope>runtime</scope>
    – Lova Chittumuri
    Nov 13 at 4:05












    Thanks, I already solved this problem. it might be the same as your solution:
    – JunHui Li
    Nov 15 at 2:05




    Thanks, I already solved this problem. it might be the same as your solution:
    – JunHui Li
    Nov 15 at 2:05












    up vote
    0
    down vote













    You can add the Shutdown hook in my application.



    Java shutdown hook runs in these two cases.




    • The program exits normally, or we call System.exit() method to terminate the program. Read more about Java System Class.

    • User interrupts such as Ctrl+C, system shutdown etc.


    Code:



    Runtime.getRuntime().addShutdownHook(new Thread("Shutdownhook") {
    public void run() {
    //code here
    //compare redis cache
    //syn data and save local file.
    try {
    mainThread.join();
    } catch (InterruptedException e) {
    // TODO Auto-generated catch block
    instance.logger.error(e.getMessage(), e);
    }
    }
    });





    share|improve this answer

























      up vote
      0
      down vote













      You can add the Shutdown hook in my application.



      Java shutdown hook runs in these two cases.




      • The program exits normally, or we call System.exit() method to terminate the program. Read more about Java System Class.

      • User interrupts such as Ctrl+C, system shutdown etc.


      Code:



      Runtime.getRuntime().addShutdownHook(new Thread("Shutdownhook") {
      public void run() {
      //code here
      //compare redis cache
      //syn data and save local file.
      try {
      mainThread.join();
      } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      instance.logger.error(e.getMessage(), e);
      }
      }
      });





      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        You can add the Shutdown hook in my application.



        Java shutdown hook runs in these two cases.




        • The program exits normally, or we call System.exit() method to terminate the program. Read more about Java System Class.

        • User interrupts such as Ctrl+C, system shutdown etc.


        Code:



        Runtime.getRuntime().addShutdownHook(new Thread("Shutdownhook") {
        public void run() {
        //code here
        //compare redis cache
        //syn data and save local file.
        try {
        mainThread.join();
        } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        instance.logger.error(e.getMessage(), e);
        }
        }
        });





        share|improve this answer












        You can add the Shutdown hook in my application.



        Java shutdown hook runs in these two cases.




        • The program exits normally, or we call System.exit() method to terminate the program. Read more about Java System Class.

        • User interrupts such as Ctrl+C, system shutdown etc.


        Code:



        Runtime.getRuntime().addShutdownHook(new Thread("Shutdownhook") {
        public void run() {
        //code here
        //compare redis cache
        //syn data and save local file.
        try {
        mainThread.join();
        } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        instance.logger.error(e.getMessage(), e);
        }
        }
        });






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 at 3:10









        VuNT

        12




        12






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53272685%2fspringboot-shutdown-automatically-and-restart-automatically%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents