在 Eclipse 中运行 Maven GWT 应用程序时出现问题

发布于 2024-11-06 08:16:53 字数 1624 浏览 7 评论 0 原文

我正在尝试通过启用 WebAppCreator 的 Maven2 创建 GWT 项目。

项目创建步骤:

  1. 使用 WebAppCreator 创建项目(我使用的是 gwt-2.3.0) ->webAppCreator -noant -maven -XnoEclipse -out MyApp com.example.MyApp
  2. 将项目导入为现有的 maven 项目在 eclipse (helios) 中
  3. 启用“项目”-> “属性”-> “谷歌”-> “Google 网络工具包”-> “使用谷歌网络工具包”复选框
  4. 在项目属性“Google”中设置 -> “网络应用程序”-> “这个项目有一个 WAR 目录”。设置 WAR 目录路径“src/main/webapp”并取消选中“从该目录启动和部署”
  5. Java 构建路径为“MyApp/target/www/WEB-INF/classes”
  6. 我没有更改 pom.xml 中的
  7. 设置 编译项目使用gwt eclipse插件(2.3.0版本)。就编译成功了。
  8. 尝试将项目作为 Web 应用程序运行。当我运行应用程序时,GWT 插件不会询问我有关 WAR 文件夹的信息。 我做了这一切,我在日志中看到:
[WARN] Server class 'com.example.server.GreetingServiceImpl' could not be found in the web app, but was found on the system classpath
   
[WARN] Adding classpath entry 'file:/home/redfox/workspace/java/redfox/MyApp/target/www/WEB-INF/classes/' to the web app classpath for this session

[WARN] Server class 'com.google.gwt.user.client.rpc.RemoteService' could not be found in the web app, but was found on the system classpath
   
[WARN] Adding classpath entry 'file:/home/redfox/.m2/repository/com/google/gwt/gwt-servlet/2.3.0/gwt-servlet-2.3.0.jar' to the web app classpath for this session

当我尝试从 URL 加载页面时 (http://127.0.0.1:8888/MyApp.html?gwt.codesvr=127.0.0.1:9997)我看到 404 错误。 在日志中我没有看到任何错误。我如何运行这个默认应用程序?我还有另一个问题:如果这个问题得到解决,我如何在 Web 模式(而不是开发模式)下运行此应用程序以使用“http://127.0.0.1:8888”之类的链接而不使用 param gwt.codesvr?

PS 抱歉我的英语不好。

I'm trying to create a GWT project through WebAppCreator enabled Maven2.

Project creation steps:

  1. Create project with WebAppCreator (i'm using gwt-2.3.0) ->webAppCreator -noant -maven -XnoEclipse -out MyApp com.example.MyApp
  2. Import project as existing maven project in eclipse (helios)
  3. Enable "Project" -> "Properties" -> "Google" -> "Google web toolkit" -> "Use google web toolkit" checkbox
  4. Set in project properties "Google" -> "Web application" -> "This project has a WAR directory". Set WAR directory path "src/main/webapp" and uncheck "launch and deploy from this directory"
  5. Java build path is "MyApp/target/www/WEB-INF/classes"
  6. I did not change the settings in pom.xml
  7. Compile project using gwt eclipse plugin (2.3.0 version). It successfully compiled.
  8. Try to run project as Web Application. When i run application GWT plugin does not ask me about WAR folder.
    I did all this, I saw in the logs:
[WARN] Server class 'com.example.server.GreetingServiceImpl' could not be found in the web app, but was found on the system classpath
   
[WARN] Adding classpath entry 'file:/home/redfox/workspace/java/redfox/MyApp/target/www/WEB-INF/classes/' to the web app classpath for this session

[WARN] Server class 'com.google.gwt.user.client.rpc.RemoteService' could not be found in the web app, but was found on the system classpath
   
[WARN] Adding classpath entry 'file:/home/redfox/.m2/repository/com/google/gwt/gwt-servlet/2.3.0/gwt-servlet-2.3.0.jar' to the web app classpath for this session

And when i try to load page from URL (http://127.0.0.1:8888/MyApp.html?gwt.codesvr=127.0.0.1:9997) i see 404 error.
In logs i don't see any errors. How can i run this default application? Also i have another question: if this problev will be solved, how can i run this application in web mode (not in development mode) for using links like "http://127.0.0.1:8888" whithout param gwt.codesvr?

P.S. Sorry for my bad English.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

难如初 2024-11-13 08:16:53

我理解您的沮丧,相信我,我最近经历了与您现在遇到的完全相同的问题。

正如尤金所指出的,按照他的指示进行操作,但是...

选择原型上选择版本2.3.0-1(其他版本可能有效,但这个对我有效)

< img src="https://i.sstatic.net/RNbdx.png" alt="选择原型">

使用 Archtype 版本生成示例应用程序。执行 mvn gwt:run,您将看到此屏幕(如果一切顺利)
单击“启动默认浏览器”。

祝你好运。
干杯
PB

启动器

I understand your frustration, trust me, I recently went through exactly the same issue you having now.

As Eugene indicated, follow his instructions, but...

On the Select an Archetype choose version 2.3.0-1 (Others may work but this one works for me)

Select an Archetype

Generate your sample app using theat Archtype version. Do a mvn gwt:run, you will see this screen (If all goes well)
Click on "Launch Default Browser".

Good luck.
Cheers
PB

Launcher

画离情绘悲伤 2024-11-13 08:16:53

我知道这个问题已经有两年了。但我刚刚遇到了同样的问题,现在知道如何解决它。

当 Eclipse 在第一次启动时不询问您的“WAR”目录时,您也可以手动设置它:

在 Eclipse 中,转到“运行”->“运行”。 “调试配置...”。选择您的“Web 应用程序”->选择“Arguments”选项卡并添加参数,例如“-war C:\YourProjectPath\target\YourProject-1.0-SNAPSHOT”。在此提供指向您的目标的完整路径,由 Maven 生成。

希望能帮助有人更快地解决这个问题:)

I know this question is two years old. But i just had the same issue and now figured out how to fix it.

When eclipse doesn't ask you at the first launch for your "WAR" directory, you can also set it manually:

In eclipse go to "Run" -> "Debug Configuration...". Select your "Web Application" -> Select the "Arguments"-Tab and add the parameter e.g. "-war C:\YourProjectPath\target\YourProject-1.0-SNAPSHOT". Provide the full path here pointing to your target, generated by maven.

Hope that helps someone solving this issue faster :)

別甾虛僞 2024-11-13 08:16:53

我知道这已经过时了,但这是我的最新方法(也回答了此处

我不能代表 webAppCreator因为我还没有使用过它,但我很幸运地使用 codehause 的 gwt-maven-plugin 在 Eclipse 中创建了 Maven 项目。

在 Eclipse 中创建 Maven GWT 项目目录

  1. 在 Eclipse 中打开新建项目向导并筛选 Maven 项目。

  2. 选择 Maven 项目并单击下一步。

  3. 输入您首选的项目位置,然后单击“下一步”。

  4. 在原型过滤器中输入“gwt-”,然后从 codehaus 中选择 gwt-maven-plugin。单击下一步。

  5. 输入您的 Maven 项目详细信息和模块值,然后单击“完成”。

这将在 Eclipse 中为您创建一个 maven - gwt 项目。它附带了一个示例应用程序,您可以使用它来确保您可以正确启动该应用程序。

运行应用程序命令行

  1. 打开命令行。
  2. 导航到您的项目主页。
  3. 运行命令“mvn clean package”。
  4. 运行命令“mvn gwt:run”

这应该可以让您启动并运行。如果您使用 2.7.0 gwt-maven-plugin,则默认情况下应该以超级开发模式运行应用程序。

在 Eclipse 中运行应用程序

  1. 正如您所做的那样,导航到 Properties >谷歌> Web 应用程序并检查“此项目有一个 WAR 目录”。使用此插件的WAR目录应该是src/main/webapp。
  2. 导航到“属性”>谷歌> Web Toolkit 并检查“此项目有一个 WAR 目录。您可以在此处指定模块。我实际上无法这样做,它可能特定于我的 Eclipse 的 Google 插件或特定于环境的东西...
  3. 运行为 > ; Web 应用程序。
  4. 如果您在步骤 2 中遇到问题,那么您将收到错误缺少必需的参数 'module[s]' 要解决此问题,请打开您的运行配置。已自动创建)并在参数中选项卡在参数末尾添加模块的包限定名称,例如 com.mycompany.abc.GwtSampleModule 不要添加“.gwt.xml”前缀。
  5. 还值得检查您的参数中引用的 HTML 页面是否正确,我也遇到过这样的问题。

现在应该使用此运行配置将应用程序配置为在 Eclipse 中启动。我验证的环境是:

  • Eclipse Luna (v4.4)
  • Google Plugin for Eclipse (v3.8)
  • GWT Maven Plugin (v2.7.0)

I know this is old, but here is my latest approach (as also answered here)

I can't speak for the webAppCreator because I haven't used it, but I have had good luck creating the Maven projects in Eclipse using the gwt-maven-plugin from codehause.

Creating a Maven GWT Project Directy in Eclipse

  1. Open the new project wizard in Eclipse and filter on Maven Project.

  2. Select the Maven Project and click next.

  3. Enter the project location of your preference and click next.

  4. Enter "gwt-" into the archetype filter and select the gwt-maven-plugin from codehaus. Click Next.

  5. Enter your maven project details and a module value, then click Finish.

This will create a maven - gwt project for you in Eclipse. This comes with a sample application that you can use to make sure you can launch the application correctly.

Running the Application Command Line

  1. Open command line.
  2. Navigate to your project home.
  3. Run the command "mvn clean package".
  4. Run the command "mvn gwt:run"

This should get you up and running. If you used the 2.7.0 gwt-maven-plugin this should run the application in super dev mode by default.

Run the application in Eclipse

  1. As you have done, navigate to Properties > Google > Web Application and check "This project has a WAR directory". The WAR directory using this plugin should be src/main/webapp.
  2. Navigate to Properties > Google > Web Toolkit and check "This project has a WAR directory. You may be able to specify the module here. I am actually unable to do so, it may be specific to my Google Plugin for Eclipse or something environment specific...
  3. Run As > Web Application.
  4. If you had issues, as I have had, in step 2 then you will get an error Missing required argument 'module[s]'. To fix this open up your run configuration (should have been auto created) and in the arguments tab add the package qualified name for your module at the end of the arguments, e.g. com.mycompany.abc.GwtSampleModule. Do not add the ".gwt.xml" prefix.
    1. It's worth also checking that the HTML page referenced in your arguments is correct, I have also had issues with that.

The application should now be configured for Launch in Eclipse using this run configuration. My verified environment is:

  • Eclipse Luna (v4.4)
  • Google Plugin for Eclipse (v3.8)
  • GWT Maven Plugin (v2.7.0)
如梦 2024-11-13 08:16:53

我的建议可能会与您的偏好略有不同,但结果会更好:)

  1. 安装 m2eclipse 插件< /强>。这将为您的环境添加许多不错的 Maven 功能。
  2. 使用新项目向导创建新的 Maven 项目
  3. 不要选择“简单项目”复选框,而是使用 GWT 原型之一(我建议 gwt-maven-plugin)

在此处输入图像描述

然后,maven 将为您创建具有所有必需依赖项的适当项目结构。有关 GWT 插件的更多信息,请访问 http://mojo .codehaus.org/gwt-maven-plugin/user-guide/archetype.html,包括如何执行它。

PS你的英语很好:)

What I suggest may start slightly different than you prefer but with better results :)

  1. Install m2eclipse plugin. This will add a lot of nice maven features to your environment.
  2. Using new project wizard create new Maven project
  3. Do not select "simple project" check box, instead use the one of GWT archetypes (I suggest gwt-maven-plugin)

enter image description here

Then appropriate project structure with all required dependencies will be created for you by maven. More info about GWT plugin can be found at http://mojo.codehaus.org/gwt-maven-plugin/user-guide/archetype.html, including on how to execute it.

P.S. Your English is fine :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文