简体   繁体   English

在eclipse上运行tomt on tomcat

[英]Running GWT on tomcat in eclipse

I am trying to get a GWT Project running on a Tomcat 7 server in eclipse. 我试图在eclipse中的Tomcat 7服务器上运行GWT项目。 I installed Tomcat and i can run other web application out of eclipse on Tomcat without a problem. 我安装了Tomcat,我可以在Tomcat上运行其他Web应用程序而没有问题。

Now i generated a gwt maven project for eclipse with the following command and importet it as maven project to eclipse: "mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin" 现在我使用以下命令为eclipse生成了一个gwt maven项目,并将其作为eclipse的maven项目导入:“mvn archetype:generate -DarchetypeGroupId = org.codehaus.mojo -DarchetypeArtifactId = gwt-maven-plugin”

I can run this now as Web application (with the google plugin) and i can build a "war" with maven and deploy this with the Tomcat management console on the server. 我现在可以将其作为Web应用程序(使用google插件)运行,我可以使用maven构建“war”并使用服务器上的Tomcat管理控制台进行部署。 Both is working. 两者都有效。 But if i choose the option in eclipse "Run on server" and choose tomcat than just the html is loaded but not the application itself. 但是,如果我选择eclipse中的选项“Run on server”并选择tomcat而不仅仅是加载html而不是应用程序本身。 See the screenshot: It doesn't find the "GWTModule.nocache.js". 请参见屏幕截图:它找不到“GWTModule.nocache.js”。

应用程序没有运行

This file is available in the target folder. 此文件位于目标文件夹中。 What do i have to change to tell tomcat to look in the correct directory? 我需要更改什么来告诉tomcat查看正确的目录?

项目布局

Tomcat is not able to run GWT code in development mode. Tomcat无法在开发模式下运行GWT代码。 You can use Tomcat for server side code, but in this case you need to run GWT development mode with -noserver option (to prevent built-in Jetty instance from running). 您可以将Tomcat用于服务器端代码,但在这种情况下,您需要使用-noserver选项运行GWT开发模式(以防止内置Jetty实例运行)。 See this article for more details. 有关详细信息,请参阅此文章

I would recommend using the wtp plugin for eclipse. 我建议使用wtp插件进行eclipse。 If you do this you can add your project/resource to tomcat when adding a new server. 如果这样做,您可以在添加新服务器时将项目/资源添加到tomcat。 Here are the steps to use if you already have your project imported into eclipse. 如果您已将项目导入到eclipse中,则可以使用以下步骤。

Window -> Show View -> Servers 窗口 - >显示视图 - >服务器

In Servers New -> Server -> Choose apache tomcat 在Servers New - > Server - >选择apache tomcat

Point to the location of your tomcat installation/download Next 指向tomcat安装/下载的位置

At this point you should be able to add your gwt-maven project which will add the target/project.war to the tomcat modules. 此时,您应该能够添加gwt-maven项目,该项目将target / project.war添加到tomcat模块。

Save it 保存

Click on the newly added server, then click the modules tab at the bottom kind of hard to see. 单击新添加的服务器,然后单击底部难以看到的模块选项卡。

This should have your project shown in the list of web modules. 这应该让您的项目显示在Web模块列表中。

Start your tomcat instance then on your gwt application right click and choose Run As -> Web application. 启动tomcat实例,然后右键单击gwt应用程序并选择Run As - > Web application。 Make sure your configuration settings are correct and when the development server starts it should give you the development url to browse to. 确保您的配置设置正确,并且当开发服务器启动时,它应该为您提供要浏览的开发URL。

You can configure some aspects of tomcat in the overview tab, I would recommend making sure that "Modules auto reload by default" is checked so that tomcat will watch the filesystem for class changes. 您可以在概述选项卡中配置tomcat的某些方面,我建议确保选中“默认情况下自动重新加载模块”,以便tomcat将监视文件系统的类更改。

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

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