[英]My Spring based Restful webservice gives 404 when deploy to standalone tomcat instead of Eclipse's Tomcat
I am using Spring, Jpa Hibernate to create a Restful Webservices. 我正在使用Spring,Jpa Hibernate创建一个Restful Web服务。 It worked fine with Eclipse's Setup of tomcat server. 在Eclipse的tomcat服务器安装程序中,它运行良好。 But when I tried to deploy its war file to standalone tomcat's webapp folder and restart the server, it gives 404 error. 但是,当我尝试将其war文件部署到独立的tomcat的webapp文件夹并重新启动服务器时,出现404错误。
What could be the cause? 可能是什么原因? Am I missing some steps while deploying to standalone tomcat? 部署到独立的tomcat时是否缺少一些步骤?
Edit: 编辑:
Turns out when packaging the war through mvn clean install
, its not packaging my web.xml and springcontext.xml. 结果是通过mvn clean install
打包战争时,没有打包我的web.xml和springcontext.xml。 When I manually copy these file to the deployed war, the project work fine. 当我手动将这些文件复制到已部署的war中时,项目工作正常。
Now the question is, do any have idea why its not packaging those file. 现在的问题是,任何人都知道为什么不打包那些文件。
By default Eclipse projects put web stuff in a folder called WebContent
. 默认情况下,Eclipse项目将Web内容放入名为WebContent
的文件夹中。 This is not where maven
expects it, so you should convert your Eclipse
project to a maven
project by using Right Click on Project->Configure->Convert to Maven
project. 这是不是哪里maven
预计,所以您应该在转换Eclipse
项目的maven
通过使用鼠标右键单击项目Project->Configure->Convert to Maven
项目。 This will build a pom.xml that references the WebContent
directory: 这将构建一个引用WebContent
目录的pom.xml:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
Here's where I'd start with the debugging: 这是我从调试开始的地方:
We do exactly what you're up to on a daily basis. 我们每天都会做您要做的事情。 We develop in Eclipse, let Tomcat auto-deploy in Dev & QA, in Prod we deploy by hand as the Manager is disabled. 我们在Eclipse中进行开发,让Tomcat在Dev&QA中进行自动部署,而在Prod中,由于Manager被禁用,我们手工部署。 Once you can get things to work in Eclipse (usually the problem) then typically it's a Tomcat config problem. 一旦可以在Eclipse中正常工作(通常是问题),那么通常就是Tomcat配置问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.