问题描述
C:\> webAppCreator -noant - maven -overwrite -out MavenTest com.raphiki.MavenTest
它使用GWT生成一个Maven项目的结构Hello世界项目,我在Eclipse中将此项目导入作为具有现有来源的Maven项目。
然后我在我的项目中启用Google Web Toolkit,我需要给一个WAR路径。我尝试使用包含入口点的 / src / main / webapp
,但是当我启动应用程序时,我会得到一个 ClassNotFoundException
on Hello world's class's package。
请看下面的图片,它是WebAppCreator构建的结构:
我错过任何配置要做吗?
我不能为webAppCreator说话,因为我没有使用它,但我已经祝你好运在Eclipse中使用gwt-maven-plugin从codehause创建Maven项目。
在Eclipse中创建Maven GWT项目Directy
在Eclipse中打开新项目向导并过滤Maven Project。
选择Maven项目,然后点击下一步。
输入您的首选项目的项目位置,然后点击下一步。
在原型过滤器中输入gwt-,并从codehaus中选择gwt-maven-plugin。单击下一步。
输入您的maven项目详细信息和模块值,然后单击完成。
这将在Eclipse中为您创建一个maven - gwt项目。这有一个示例应用程序,您可以使用它来确保您可以正确启动应用程序。
运行应用程序命令行
打开命令行。
导航到您的项目主页。
运行命令mvn clean package。
运行命令mvn gwt:run
这应该让你开始运行。如果你使用2.7.0 gwt-maven-plugin,那么这个应用程序在默认情况下应该以超级模式运行。
在Eclipse中运行应用程序
如您所做,导航到属性> Google> Web应用程序,然后选中此项目有一个WAR目录。使用此插件的WAR目录应为src / main / webapp。
导航到属性>Google>Web工具包,然后选中此项目具有WAR目录,您可以指定我实际上无法做到这一点,可能是针对我的Google插件Eclipse或特定环境特定的...
运行方式> Web应用程序。
如果你有问题,就像我曾经有过的那样,在步骤2中,你会得到一个错误
缺少必需的参数'module's''
这将打开您的运行配置(应该已经自动创建),在参数选项卡中,在参数末尾添加模块的包限定名,例如com.mycompany.abc.GwtSampleModule。不要添加.gwt。 xml前缀还要检查参数中引用的HTML页面是否正确,我也有问题。
应用程序现在应该是配置使用此运行配置在Eclipse中启动。我验证的环境是:
Eclipse Luna(v4.4)
Google Eclipse插件v3.8)
GWT Maven插件(v2.7.0)
I'm starting a GWT project with web creator as following:
C:\>webAppCreator -noant -maven -overwrite -out MavenTest com.raphiki.MavenTest
It generates a Maven project's structure with an GWT Hello world project, I import this project in Eclipse as a Maven project with existing sources.
Then I enable Google Web Toolkit in my project, and I need to give a WAR path. I try with the /src/main/webapp
which contains the entry point, but when I launch the app I get a ClassNotFoundException
on Hello world's class's package.
See the following image which is the structure the WebAppCreator built:
Did I miss any configuration to do?
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
- Open command line.Navigate to your project home.Run the command "mvn clean package".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
- 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.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... Run As > Web Application.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.- 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)
这篇关于Eclipse配置使用Google Web Toolkit启动Maven项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!