Skip to content

spring

webdesc
springboot
to yaml

配置热部署devtools工具

xml
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional> <!-- 可以防止将devtools依赖传递到其他模块中 -->
</dependency>
yaml
# application.yaml

spring:
  devtools:
    restart:
      enabled: true  #设置开启热部署
      additional-paths: src/main/java #重启目录
      exclude: WEB-INF/**  #排除一些不需要自动重启的资源
  thymeleaf:
    cache: false #使用Thymeleaf模板引擎,关闭缓存

pom.xml中添加<fork>true</fork

xml
<!--pom.xml-->
<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <configuration>
                    <mainClass>com.example.springbootdemo.SpringbootdemoApplication</mainClass>
                    <skip>true</skip>
                    <fork>true</fork>
                </configuration>
                <executions>
                    <execution>
                        <id>repackage</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

设置build,execution,deployment>compiler>build project automatically勾上

设置advanced settings>allow auto-make to start even if developed application is currently running勾上