简体   繁体   English

尝试将tomcat与eclipse一起使用

[英]Trying to use tomcat with eclipse

I am trying to use tomcat with eclipse. 我正在尝试使用带有eclipse的tomcat。 I have installed it all and got the tomcat plugin installed. 我已经安装了所有东西,并安装了tomcat插件。 I have put a .war file in the webapps folder of tomcat and have made sure autodeploy is set to true. 我已将.war文件放入tomcat的webapps文件夹中,并确保将autodeploy设置为true。 The problem I am having is that I can't get tomcat to run this .war file. 我遇到的问题是我无法让tomcat运行此.war文件。 The tomcat server is started and running as it tells me under the servers tab at the bottom of eclipse. tomcat服务器已启动并正在运行,它在Eclipse底部的“服务器”选项卡下告诉我。 It also shows the name of my .war file under it and says synchronized meaning it at least knows its there. 它还在其下显示我的.war文件的名称,并说“已同步”,这意味着它至少知道该文件的存在。 But I can't get it to work at all. 但是我根本无法使用它。 Even when I go to the local host page it shows the title of apache tomcat but does not show the file. 即使我转到本地主机页面,它也显示apache tomcat的标题,但不显示文件。 I want it to show me the .war file. 我希望它向我显示.war文件。 It has the correct xml files and everything in it. 它具有正确的xml文件以及其中的所有内容。 Any help is much appreciated. 任何帮助深表感谢。

You may try to check whether the application is deployed or not. 您可以尝试检查应用程序是否已部署。 You can directly go to the Tomcat directory to see this. 您可以直接转到Tomcat目录以查看此内容。

Another possible thing could be, you might be typing the incorrect url. 另一可能的情况是,您输入的网址可能不正确。 http://localhost:8080/[your_application] HTTP://本地主机:8080 / [your_application]

where 8080 is the port you have specified for tomcat. 其中8080​​是您为tomcat指定的端口。

You need to let Eclipse publish your web project for you when using the Eclipse Tomcat plugin instead of trying to manually deploy it youself. 使用Eclipse Tomcat插件时,需要让Eclipse为您发布Web项目,而不是尝试自己手动部署它。

The Tomcat plugin for Eclipe supports hot deployment whereby you can change jsp's etc without having to manually redeploy your web application. 用于Eclipe的Tomcat插件支持热部署,因此您可以更改jsp的内容,而无需手动重新部署Web应用程序。

If you have a valid web project in eclipse then you can check that it is being deployed by looking at the Server View. 如果您在Eclipse中有一个有效的Web项目,则可以通过查看服务器视图来检查它是否正在部署。

Window, Show View, Other, Server 窗口,显示视图,其他,服务器

This window should contain details of your Apache server. 该窗口应包含您的Apache服务器的详细信息。 (If no server is listed then you'll need to right click on the list and set one up.) (如果未列出任何服务器,则需要右键单击列表并进行设置。)

To check that your application is being deployed right click on your server and select Add/Remove projects. 要检查您的应用程序是否已部署,请右键单击服务器,然后选择“添加/删除项目”。 Check that your web project is listed. 检查是否列出了您的Web项目。 If it is not listed under Configured Project then add it. 如果未在“配置的项目”下列出,则添加它。

If your project does not appear in the list then it probably wasn't setup as a Dynamic Web Project. 如果您的项目未出现在列表中,则可能未将其设置为动态Web项目。 You can fix this by by right clicking on the project to bring up project properties and then clicking on facets and then enabling Dynamic Web Project. 您可以通过以下方法解决此问题:右键单击项目以调出项目属性,然后单击构面,然后启用动态Web项目。

It is also worth having the Console view visible when starting/stopping Tomcat so that you can see the server output. 在启动/停止Tomcat时使控制台视图可见也是值得的,这样您就可以看到服务器输出。

Start tomcat from the command line (not eclipse) and see if your webapp shows up. 从命令行(不是Eclipse)启动tomcat,然后查看您的webapp是否显示。 It should if you have indeed created a valid war file. 如果确实已经创建了有效的war文件,则应该这样做。 If it doesn't work, check the logs. 如果不起作用,请检查日志。

You shouldn't be manually deploying the war file if you are using eclipse to launch tomcat. 如果您使用eclipse启动tomcat,则不应手动部署war文件。 Running tomcat from eclipse does not necessarily use the same default workspace as the standalone tomcat. 从eclipse运行tomcat不一定要使用与独立tomcat相同的默认工作区。 Check the configurations for the 'server': it may be that the eclipse launched server's webapp folder is empty. 检查“服务器”的配置:可能是Eclipse启动的服务器的webapp文件夹为空。

如果由于某种原因您的web应用未能正确初始化(描述符错误,上下文侦听器中未捕获的异常,...),tomcat将卸载它,并且您不会在http:// localhost:8080 / yourwebapp看到任何内容。

Is it there in the list of applications in tomcat manager? 在tomcat管理器中的应用程序列表中有吗? if you havent done this...then follow the steps... Go to http://localhost:8080/ Go to Tomcat manager and check if your application is there in the list of deployed applications. 如果尚未执行此操作,请按照以下步骤操作:转至http:// localhost:8080 /转至Tomcat管理器,并检查您的应用程序是否在已部署的应用程序列表中。 Try redeploying or starting the application if running=false. 如果运行= false,请尝试重新部署或启动应用程序。 It usually tells you what is wrong when you do that. 它通常会告诉您这样做时出了什么问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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