我正在尝试通过启用 WebAppCreator 的 Maven2 创建 GWT 项目。
项目创建步骤:
- 使用 WebAppCreator 创建项目(我使用的是 gwt-2.3.0) ->webAppCreator -noant -maven -XnoEclipse -out MyApp com.example.MyApp
- 将项目导入为现有的 maven 项目在 eclipse (helios) 中
- 启用“项目”-> “属性”-> “谷歌”-> “Google 网络工具包”-> “使用谷歌网络工具包”复选框
- 在项目属性“Google”中设置 -> “网络应用程序”-> “这个项目有一个 WAR 目录”。设置 WAR 目录路径“src/main/webapp”并取消选中“从该目录启动和部署”
- Java 构建路径为“MyApp/target/www/WEB-INF/classes”
- 我没有更改 pom.xml 中的
- 设置 编译项目使用gwt eclipse插件(2.3.0版本)。就编译成功了。
- 尝试将项目作为 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:
- Create project with WebAppCreator (i'm using gwt-2.3.0) ->webAppCreator -noant -maven -XnoEclipse -out MyApp com.example.MyApp
- Import project as existing maven project in eclipse (helios)
- Enable "Project" -> "Properties" -> "Google" -> "Google web toolkit" -> "Use google web toolkit" checkbox
- 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"
- Java build path is "MyApp/target/www/WEB-INF/classes"
- I did not change the settings in pom.xml
- Compile project using gwt eclipse plugin (2.3.0 version). It successfully compiled.
- 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.
发布评论
评论(4)
我理解您的沮丧,相信我,我最近经历了与您现在遇到的完全相同的问题。
正如尤金所指出的,按照他的指示进行操作,但是...
在
选择原型
上选择版本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 version2.3.0-1
(Others may work but this one works for me)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
我知道这个问题已经有两年了。但我刚刚遇到了同样的问题,现在知道如何解决它。
当 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 :)
我知道这已经过时了,但这是我的最新方法(也回答了此处)
我不能代表 webAppCreator因为我还没有使用过它,但我很幸运地使用 codehause 的 gwt-maven-plugin 在 Eclipse 中创建了 Maven 项目。
在 Eclipse 中创建 Maven GWT 项目目录
在 Eclipse 中打开新建项目向导并筛选 Maven 项目。
选择 Maven 项目并单击下一步。
输入您首选的项目位置,然后单击“下一步”。
在原型过滤器中输入“gwt-”,然后从 codehaus 中选择 gwt-maven-plugin。单击下一步。
输入您的 Maven 项目详细信息和模块值,然后单击“完成”。
这将在 Eclipse 中为您创建一个 maven - gwt 项目。它附带了一个示例应用程序,您可以使用它来确保您可以正确启动该应用程序。
运行应用程序命令行
这应该可以让您启动并运行。如果您使用 2.7.0 gwt-maven-plugin,则默认情况下应该以超级开发模式运行应用程序。
在 Eclipse 中运行应用程序
缺少必需的参数 'module[s]'
要解决此问题,请打开您的运行配置。已自动创建)并在参数中选项卡在参数末尾添加模块的包限定名称,例如 com.mycompany.abc.GwtSampleModule 不要添加“.gwt.xml”前缀。现在应该使用此运行配置将应用程序配置为在 Eclipse 中启动。我验证的环境是:
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
Open the new project wizard in Eclipse and filter on Maven Project.
Select the Maven Project and click next.
Enter the project location of your preference and click next.
Enter "gwt-" into the archetype filter and select the gwt-maven-plugin from codehaus. Click Next.
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
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
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.The application should now be configured for Launch in Eclipse using this run configuration. My verified environment is:
我的建议可能会与您的偏好略有不同,但结果会更好:)
然后,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 :)
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 :)