首页 > 技术文章 > IDEA 2020.1 热部署(不安装JRebel)

xfyuao 2020-09-08 11:19 原文

 IDEA不需要安装JRebel即可实现热部署。

    版本:IDEA 2020.1 

    日期:2020-09-08 11:07:40

    需要三步:pom依赖、Settings设置、特殊设置

1.pom文件中要有devtools依赖和maven-plugin插件:

 <!-- dependencys内 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>

 

<!--build的plgins里,一般会自动生成-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.3.0.RELEASE</version>
                <configuration>
                    <!-- 你自己的 -->
                    <mainClass>com.example.demo.DemoApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <id>repackage</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

 

2.在设置中打开自动编译:

 

 

 3.打开运行时编译,按快捷键 Shift+Ctrl+Alt+/ ,选择 Registry,找到找到compiler.automake.allow.when.app.running进行勾选,然后Close

 

 

 

   然后就可以了。

  还可以在application.properties配置文件添加如下配置,做一些自定义设置,一般也没多大用,不配置也能用:

#热部署生效
spring.devtools.restart.enabled=true
#设置重启的目录
spring.devtools.restart.additional-paths=src/main/java
#设置不重启目录
spring.devtools.restart.exclude=WEB-INF/** 

  最后,以上种种,mybatis的mapper.xml文件能否热部署并没有尝试,尝试过的可以在下方留言惠及大家。

推荐阅读