【问题标题】:Why spring boot devtools called main method twice?为什么spring boot devtools两次调用main方法?
【发布时间】:2018-05-22 08:35:47
【问题描述】:

我在我的项目中使用 spring boot devtools。当我写的时候

System.out.println("test");

在 main 之前,它会在控制台中打印两次。

public static void main(String[] args) {

    System.out.println("test");
    SpringApplication.run(TestApplication.class, args);
}

当我删除时

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

在 pom.xml 文件中,打印一次

【问题讨论】:

    标签: spring-boot spring-boot-devtools


    【解决方案1】:

    不止两次,如果spring上下文需要刷新,会再运行一次。

    我相信这是一种设计行为。

    开发工具会自动刷新上下文,而不是手动重新启动。

    【讨论】:

    • 这让我们的 QA 环境变得非常疯狂。
    猜你喜欢
    • 1970-01-01
    • 2021-11-26
    • 1970-01-01
    • 2012-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-31
    • 2016-09-29
    相关资源
    最近更新 更多