【springboot】spring-boot-devtools 热部署 导致 mvn spring-boot:run 出现异常

mac2023-01-25  22

前言

- spring boot 2.0.0.RELEASE

操作

<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> </configuration> </plugin> </plugins> </build>

此处要特别提到fork参数。该参数的说明:

Flag to indicate if the run processes should be forked. Disabling forking will disable some features such as an agent, custom JVM arguments, devtools or specifying the working directory to use. Default value is: true. User property is: spring-boot.run.fork. Since: 1.2.0

虽然不明觉厉,但是还真碰到了需要该参数的情况。 在一个项目中发现():mvn spring-boot:run启动项目屡次失败。最后发现,将pom.xml中的spring-boot-devtools去掉就可以启动了。来回添加、去掉spring-boot-devtools还是很麻烦的。将fork这个参数设置成false,就不用来回添加、去掉spring-boot-devtools了。

最新回复(0)