我正在使用Maven项目学习Spring,我面临一个问题。这是我的控制器:
@Controller
public class HelloWorldController {
@RequestMapping("/hello")
public String hello(Model model) {
model.addAttribute("greeting", "Hello Spring MVC");
return "helloworld";
}
}我以这种方式运行我的项目(我使用Eclip ):右键单击project > Run > Right >右键单击Maven Build > New > Enter name、基目录和目标> Apply > Run。好了。
当我访问这个网址时
http://localhost:8080/DemoSpringMVC/hello
将显示"helloworld"页面,这很简单。
现在我想将@RequestMapping("/hello")改为@RequestMapping("/hello1"),如下所示
@Controller
public class HelloWorldController {
@RequestMapping("/hello1")
public String hello(Model model) {
model.addAttribute("greeting", "Hello Spring MVC");
return "helloworld";
}
}我再次运行我的项目,访问这个url并得到错误"The requested resource is not available."“
http://localhost:8080/DemoSpringMVC/hello1
我试着访问它,"helloworld"仍然被显示
http://localhost:8080/DemoSpringMVC/hello
我打开任务管理器,发现每次运行项目时,"javaw.exe"都会创建一个新实例,但是旧版本总是会受到影响。我尝试手工杀死所有的"javaw.exe"进程,再次运行该项目,它就能工作了。
所以问题是,每当我运行我的项目时,如何杀死旧的"javaw.exe"过程?或者我可能错误地构建或运行Maven项目?
解决了:我意识到我可以按照正常的方式运行maven项目(通过tomcat),然后问题就解决了。谢谢你们所有人。
发布于 2017-04-08 13:24:53
您可能希望重新部署运行中的代码,而不是第二次运行。请参阅https://www.mkyong.com/eclipse/how-to-configure-hot-deploy-in-eclipse/
https://stackoverflow.com/questions/43292711
复制相似问题