Eclipse和idea 基于springboot 配置热部署

1.导入依赖包

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

2.在 plugin 中配置另外⼀一个属性 fork,并且配置为 true。

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

3.如果你是eclipse用户,那么配置完这些就可以实现热部署了,若是idea用户还要配置idea
选择 File | Settings | Compiler 命令,然后勾选 Build project automatically 复选框
在这里插入图片描述
4.使⽤用快捷键 Ctrl + Shift + A,在输⼊入框中输⼊入 Registry,勾选 compile.automake.allow.when.app.running 复
选框:

在这里插入图片描述
5.然后改动代码,就会发现springboot会自动重新加载项目

6.为什么 IDEA 需要多配置后面这一步呢?因为 IDEA 默认不是⾃动编译的,需要我们手动去配置后才会自动编译,而热部署依赖于项目的⾃动编译功能。

猜你喜欢

转载自blog.csdn.net/qq_40974235/article/details/107316757