天天看點

IDEA使用Jrebel運作SpringBoot項目

IDEA 中配置 Jrebel

1、打開IDEA Preferences 界面,Compiler—> 勾選 Build project automatically。

IDEA使用Jrebel運作SpringBoot項目

2、按組合鍵 Shift+Ctrl+Alt+/,填入 Registry,點選 Registry。

IDEA使用Jrebel運作SpringBoot項目

勾選上文本框 compiler.automake.allow.when.app.running

IDEA使用Jrebel運作SpringBoot項目

使用Jrebel 運作SpringBoot項目

1、建立 SpringBoot 項目,啟動類檔案 右擊用 Rebel Run ‘DemoApplication’ 運作。

IDEA使用Jrebel運作SpringBoot項目

2、驗證 Jrebel 熱部署

添加 DemoController 控制類

@RestController
public class DemoController {

    @GetMapping("test")
    public String test(){
        return "hello world!";
    }
}
           

通路 http://localhost:8081/test ,輸出:hello world!

添加一個新方法,儲存之後,不用重新開機項目。稍等一會,控制台輸出更改的檔案。

IDEA使用Jrebel運作SpringBoot項目

通路 http://localhost:8081/test1 ,輸出 :hello,java!,熱部署成功。