我之前开发一直使用eclipse,现在由于要写一些前端代码(比如vue之类的),因idea对前后端代码开发支持都比较全面(主要是插件丰富,还有一个webstorm与idea是同一家公司研发的)所以安装了idea(我使用的是IntelliJ IDEA 2019.3.3旗舰版,register过程见我另一篇blog:);
顺利安装并register 了idea之后就创建了springboot的helloword程序,创建过程此处就不说了(如果你没有学过spring boot的话请自行到官网查看),我在这里只贴出用于测试的HelloController代码:
@RestController
public class HelloController {
@GetMapping("/hello")
public String hello(){
String str = "hello 1";
System.out.println(str);
return str;
}
}
运行spring boot启动类程序并在浏览器中访问http://localhost:8080/hello,在idea的console和浏览器中成功打印了内容“hello 1”,这样spring boot的hellowrod程序就写好了,然后我修改了str的内容为String str = "hello 2";刷新浏览器就奇怪了?怎么还是打印“hello 1”什么情况??怎么与使用eclipse时不一样(在eclipse中如果修改了某controller方法体内容是可以实时生效的,在idea中必须要重新运行程序,瞬间感觉idea好弱)???在网上找到的结果是需要设置idea的EDIT Configurations中的springboot配置,具体方式如下:
或者
然后设置running application update policies内容为update classes and resources
设置完毕之后修改str=“hello 2”然后刷新浏览器,总算是实时生效了(并提示有一个class reloaded了),效果如下: