如何从Java部署Java Web应用程序项目以实现Tomcat服务器?

问题描述:

我已经开发了一个使用HTML,Java Servlet和所有的Web应用程序。在开发我正在使用Tomcat来部署它以测试它。

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.

现在我的开发完成了,我想让它活着。因为我们有现场服务器,但由于我是全新的,我不知道如何在现场服务器上部署我的java Web应用程序。

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?

所以请帮助我,如果你知道要解答?

So please help me if you know to answer?

我的项目结构

     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

我也在使用MySql,所以我有关于它..

I am also using MySql so what I have to about it..


  1. 您将必须构建一个项目的WAR。
    您可以在eclipse中执行此操作

  1. You will have to build a WAR of the project. You can do this


  • :右键单击项目,单击导出,然后在对话框(并提及目的地,名称和所有)

  • 通过ant使用 war 任务

ant选项更好,因为当您在项目中有多个开发人员并且代码处于版本控制时,这更容易自动获取项目(使用蚂蚁)并建立战争。 (你有版本控制,不是吗?)

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 operational difference (albeit an important one) but the war created in either way are same

将战争部署到服务器


  • 您可以手动将war文件复制到$ TOMCAT_HOME / webapps目录(请参阅创建和部署WAR文件一节中的这篇文章

您可以使用Tomcat 6 管理器应用程序

You can use the Tomcat 6 "Manager" application.

更新

你说你也在使用MySql。应该将MySql安装在服务器上(它可以在同一台服务器上),并且应该更改配置(用户名,密码,服务器详细信息),以便应用程序连接到同一个数据库(我确定您不是在应用程序中对数据库详细信息和凭据进行硬编码,并从某些配置中读取它们,这是必须更改的配置)

Update
You said that you are using MySql also. MySql should be installed on a server (it can be 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)