如何将 Java Web 应用程序项目从 Eclipse 部署到实时 Tomcat 服务器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6546430/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to deploy Java web application project from Eclipse to live Tomcat server?
提问by mahesh
I have developed an web application using HTML, Java Servlet and all. While developing I was using Tomcat to deploy it in order to test it.
我已经使用 HTML、Java Servlet 等开发了一个 Web 应用程序。在开发时,我使用 Tomcat 来部署它以对其进行测试。
Now my development is done and I want to make it live. For that we have live server but as I am new to all this I dont know how to deploy my java web application on live server?
现在我的开发已经完成,我想让它上线。为此,我们有实时服务器,但由于我对这一切都不熟悉,我不知道如何在实时服务器上部署我的 Java Web 应用程序?
So please help me if you know to answer?
所以如果你知道回答,请帮助我?
My Project Structure
我的项目结构
ProjectName
->src
->beanClass
->class1
->Class2
->easyServlet
->Servlet1
->Servlet2
->Servlet3
->easyTrans
->Class1
->Class2
->Class3
->Class4
->build
->WebContent
->META-INF
->MENIFEST.mf
->WEB-INF
->lib(contain javascript files)
->web.xml
->html1
->html2
->html3
->html4
->html5
I am also using MySql so what I have to about it..
我也在使用 MySql,所以我必须做些什么..
采纳答案by Nivas
You will have to build a WAR of the project. You can do this
- in eclipse: right click on the project, Click "Export", and choose war file in the dialog (and mention, the destination, name and all)
via ant using the wartask
The ant option is better because when you have multiple developers on the project and the code is in version control, it is easier to get the project automatically (using ant) and build a war. (you have version control, don't you?)
But this is more of an operationaldifference (albeit an important one) but the war created in either way are same
Deploy the war to the server
You can manually copy the war file to the $TOMCAT_HOME/webapps directory (See the "Creating and Deploying a WAR File" section on this article)
You can use the Tomcat 6 "Manager" application.
您将必须构建项目的 WAR。你可以这样做
- 在eclipse中:右键单击项目,单击“导出”,然后在对话框中选择war文件(并提及,目的地,名称等)
通过 ant 使用war任务
ant 选项更好,因为当项目有多个开发人员并且代码处于版本控制中时,更容易自动获取项目(使用 ant)并构建War。(你有版本控制,不是吗?)
但这更多是操作上的差异(尽管很重要)但以任何一种方式造成的War都是相同的
将War部署到服务器
Update
You said that you are using MySql also. MySql should be installed on a server (it canbe on the same server) and the configuration should be changed (username, password, server details) so that the application connects to the same database (I am sure you are not hard coding database details and credentials in your application and reading them from some configuration, this is the configuration that has to be changed)
更新
你说你也在使用 MySql。MySql 应该安装在服务器上(它可以在同一台服务器上)并且应该更改配置(用户名、密码、服务器详细信息),以便应用程序连接到同一个数据库(我确定您不是硬编码数据库详细信息)和应用程序中的凭据并从某些配置中读取它们,这是必须更改的配置)
回答by Jigar Joshi
For that we have live server but as I am new to all this I dont know how to deploy my java web application on live server?
为此,我们有实时服务器,但由于我对这一切都不熟悉,我不知道如何在实时服务器上部署我的 Java Web 应用程序?
I assume by this you meant , you have a public IP assigned to a server. Now you can install tomcat into this server and open the tomcat port for public and you will be able to access.
我假设您的意思是,您有一个分配给服务器的公共 IP。现在你可以把tomcat安装到这个服务器上,并且开放tomcat端口给public,你就可以访问了。
Now build a war file of your webapplication and put it into web-apps dir of the tomcat and start the server
现在构建一个 web 应用程序的 war 文件并将其放入 tomcat 的 web-apps 目录并启动服务器
回答by manku
Making a few assumptions here. You need
在这里做一些假设。你需要
- A tomcat instance running on your production server
- Permissions to make changes to the tomcat instance
- A war file that bundles your application
- 在您的生产服务器上运行的 tomcat 实例
- 对 tomcat 实例进行更改的权限
- 捆绑您的应用程序的 war 文件
If you have both, then you need to navigate to the Tomcat manager page and follow the instructions to upload your war file.
如果两者都有,那么您需要导航到 Tomcat 管理器页面并按照说明上传您的 war 文件。
回答by john
Deploy the war to the server
将War部署到服务器
You can manually copy the war file to the $TOMCAT_HOME/webapps
directory.
您可以手动将war文件复制到$TOMCAT_HOME/webapps
目录中。
You can use the Tomcat 6 "Manager" application.
您可以使用 Tomcat 6“管理器”应用程序。