问题描述
我花了整个周末试图运行一些简单的Spring REST应用程序.网上有很多例子.但是,每当我要运行这些文件时,我的应用程序总会给我一个404-找不到资源异常.为了确保一切正常,我什至从头开始重新启动了几次应用程序.
I have spent the weekend trying to run some simple Spring REST applications. Lots of examples on the net. However, whenever I got to running these, my application would always give me a 404 - Resource not found exception. To ensure I was doing everything right, I even restarted the applications from scratch a few times.
如果我转到项目文件夹并运行mvn tomcat7:运行该项目将按预期工作.但是,将项目添加到Eclipse中的Tomcat7服务器中并在其中运行时,总是会出现404错误.
If I go to the project folder and run mvn tomcat7:run the project works as expected. However, when adding the project to my Tomcat7 server inside Eclipse and running it there, I always get a 404 error.
任何关于出问题的想法将不胜感激.
Any ideas on what is going wrong would be greatly appreciated.
推荐答案
我认为问题是src/main/java
folder
,您说您是手动创建它的.因此您没有在创建后将其添加到源吗?
I think the problem is src/main/java
folder
, you said you manually create it. so you did not add it to Source after create it?
更新我只是将代码导入到eclipse中,然后修改了 Web Module
Path
,就可以了.这是快照:
Updatei just import the code to eclipse,and i modify the Web Module
Path
,and it worked. here is the snap:
和测试网址
希望这很有用.
这篇关于无法使用Tomcat运行Spring REST应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!