多语言展示
当前在线:458今日阅读:103今日分享:49

intellij idea设置SpringBoot实现项目的热部署

intellij idea设置SpringBoot实现项目的热部署。
工具/原料
1

SpringBoot

2

Intellij IDEA

方法/步骤
1

在SpringBoot的开发中,我们可以通过配置解决程序更改代码之后的重新启动问题,即SpringBoot 项目 热部署。在pom.xml文件中增加相关依赖包:            org.springframework            springloaded                            org.springframework.boot            spring-boot-devtools       

3

修改Intellij idea配置,设置项目自动编译。选择File->Settings。

4

选中Build project automatically。

5

在intellij idea中同时操作:ctrl+alt+a,选择Register...勾选上:ompiler.automake.allow.when.app.running。

6

现在来测试一下这个设置是否生效。启动SpringBoot主程序。在浏览器中访问地址:http://localhost/。我们修改一下程序代码:package com.gwolf.controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.*;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;@RestControllerpublic class HelloController {        @RequestMapping(value='/echo/{message}',            method = RequestMethod.GET)    public String echo(@PathVariable('message') String msg) {        return '[echo11]' + msg;    }        @RequestMapping('/')    public  String hello(HttpServletRequest request,                          HttpServletResponse response) {        System.out.println('客户端地址:' + request.getRemoteAddr());        System.out.println('取得客户端相应编码:' + response.getCharacterEncoding());        System.out.println('取得SessionID:' + request.getSession().getId());        System.out.println('取得项目真实路径:' +                 request.getServletContext().getRealPath('/upload'));        return 'www.baidu.com168';    }}不重启应用,重新访问地址:输出结果已经变化了。

推荐信息