java spring boot 项目 热加载 有利于快速开发

版权声明:原创文章欢迎转载,不过要记得加出处哦 https://blog.csdn.net/wljk506/article/details/82526651

spring boot devtools 方式

pox.xml

加入

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional><!--true 热部署才有效,表示覆盖父级项目中的引用-->
    <scope>true</scope>
</dependency>

修改或者加入

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

fox.风

配置修改

IDEA开启项目自动编译

WIN

settings->Build,Execution,Deployment->compiler
在右侧的配置项中Build project automatically 前面选中

MAC

Preferences->Build,Execution,Deployment->compiler
在右侧的配置项中Build project automatically 前面选中

IDEA开启项目运行时自动make

WIN

ctrl + shift + /
搜索命令:registry -> 勾选compiler.automake.allow.when.app.running

MAC

shift + option + command +/
搜索命令:registry -> 勾选compiler.automake.allow.when.app.running

spring loaded

修改 或者 加入

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <fork>true</fork>
    </configuration>
    <dependencies>
        <!-- spring热部署-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>springloaded</artifactId>
            <version>1.2.8.RELEASE</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</plugin>

以下操作java文件时,系统会监视classes文件,当有classes文件被改动时,系统会重新加载类文件,不用重启启动服务
1. 右键 application debug 启动
2. 系统通过 mvn spring-boot:run启动
3. 使用导航栏,快速操作按钮 小乌龟debug

猜你喜欢

转载自blog.csdn.net/wljk506/article/details/82526651