【SpringBoot】热部署

spring-boot-devtools 方式

pom文件

<dependency>
	<groupId>org.springframework.bootgroupId>
	<artifactId>spring-boot-devtoolsartifactId>
	<optional>trueoptional>
dependency>

application.properties

#热部署
spring.devtools.restart.enabled=true
spring.devtools.restart.additional-paths=src/main/java
#关闭缓存,及时刷新
#spring.thymeleaf.cache=false
#排除无需热部署目录
#spring.devtools.restart.exclude=static/**,public/**
#srping.devtools.restart.exclude=WEB-INF/**

IDEA 配置

1.Build project automatically
【SpringBoot】热部署_第1张图片

2.Shift+Ctrl+Alt+/ -> Registry -> compiler.automake.allow.when.app.running
【SpringBoot】热部署_第2张图片

参考:
https://www.cnblogs.com/jiangbei/p/8439394.html
https://blog.csdn.net/u012190514/article/details/79951258
https://blog.csdn.net/isea533/article/details/70495714

 

Spring Loaded 方式

pom 文件

<dependencies>
	<dependency>
	    <groupId>org.springframeworkgroupId>
	    <artifactId>springloadedartifactId>
	    <version>1.2.6.RELEASEversion>
	dependency>
dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-maven-pluginartifactId>
            <dependencies>
                <dependency>
                    <groupId>org.springframeworkgroupId>
                    <artifactId>springloadedartifactId>
                    <version>1.2.6.RELEASEversion>
                dependency>
            dependencies>
            
            <configuration>
                <mainClass>com.xuxd.WebApplicationmainClass>
            configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackagegoal>
                    goals>
                execution>
            executions>
        plugin>
    plugins>
build>

启动方式

1.使用 spring boot:run 命令

2.配置 VM Options
【SpringBoot】热部署_第3张图片

参考:https://blog.csdn.net/x763795151/article/details/72852608

 

小结

推荐使用 spring-boot-devtools方式,支持的更多,同时Spring Loaded方式会产生端口占用的问题

你可能感兴趣的:(【,Java,】,………SpringBoot)