SpringBoot
Intellij IDEA
在SpringBoot的开发中,我们可以通过配置解决程序更改代码之后的重新启动问题,即SpringBoot 项目 热部署。在pom.xml文件中增加相关依赖包:
修改Intellij idea配置,设置项目自动编译。选择File->Settings。
选中Build project automatically。
在intellij idea中同时操作:ctrl+alt+a,选择Register...勾选上:ompiler.automake.allow.when.app.running。
现在来测试一下这个设置是否生效。启动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'; }}不重启应用,重新访问地址:输出结果已经变化了。