简体   繁体   中英

Unable to run Spring REST application using Tomcat

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.

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.

项目布局1

项目布局2

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?

Update i just import the code to eclipse,and i modify the Web Module Path ,and it worked. here is the snap: 在此处输入图片说明

and the test url 在此处输入图片说明

hope this is useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM