简体   繁体   English

使用 WebAppCreator 制作的 GWT Maven 项目在开发模式下不起作用

[英]GWT Maven project made with WebAppCreator don't work in devmode

I have created a GWT project with maven configuration on this way :我以这种方式创建了一个带有 Maven 配置的 GWT 项目:

webAppCreator -out HelloWorldGWT -templates sample,maven,readme ua.vitvyaz.hellowordgwt.HelloWorldGWT

I tried to run project on devmode :我试图在 devmode 上运行项目:

mvn gwt:devmode

But in the browser i got :但是在浏览器中我得到了:

"HTTP ERROR 404 

Problem accessing /HelloWorldGWT.html.

Reason: Not Found"

I looked, the directory WEB-INF was empty.我一看,目录WEB-INF是空的。

What is wrong in pom.xml ? pom.xml什么问题?

pom.xml: pom.xml:

 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <!-- POM file generated with GWT webAppCreator --> <modelVersion>4.0.0</modelVersion> <groupId>ua.vitvyaz.hellowordgwt</groupId> <artifactId>HelloWorldGWT</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>ua.vitvyaz.hellowordgwt.HelloWorldGWT</name> <properties> <!-- Setting maven.compiler.source to something different to 1.8 needs that you configure the sourceLevel in gwt-maven-plugin since GWT compiler 2.8 requires 1.8 (see gwt-maven-plugin block below) --> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <!-- Don't let your Mac use a crazy non-standard encoding --> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> </properties> <dependencyManagement> <dependencies> <!-- ensure all GWT deps use the same version (unless overridden) --> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt</artifactId> <version>2.8.0-rc1</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-servlet</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-user</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-dev</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> </dependencies> <build> <!-- Output classes directly into the webapp, so that IDEs and "mvn process-classes" update them in DevMode --> <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory> <plugins> <!-- GWT Maven Plugin--> <plugin> <groupId>net.ltgt.gwt.maven</groupId> <artifactId>gwt-maven-plugin</artifactId> <version>1.0-rc-6</version> <executions> <execution> <goals> <goal>import-sources</goal> <goal>compile</goal> <goal>import-test-sources</goal> <goal>test</goal> </goals> </execution> </executions> <configuration> <moduleName>ua.vitvyaz.hellowordgwt.HelloWorldGWT</moduleName> <moduleShortName>HelloWorldGWT</moduleShortName> <failOnError>true</failOnError> <!-- GWT compiler 2.8 requires 1.8, hence define sourceLevel here if you use a different source language for java compilation --> <sourceLevel>1.8</sourceLevel> <!-- Compiler configuration --> <compilerArgs> <!-- Ask GWT to create the Story of Your Compile (SOYC) (gwt:compile) --> <arg>-compileReport</arg> <arg>-XcompilerMetrics</arg> </compilerArgs> <!-- DevMode configuration --> <warDir>${project.build.directory}/${project.build.finalName}</warDir> <classpathScope>compile+runtime</classpathScope> <!-- URL(s) that should be opened by DevMode (gwt:devmode). --> <startupUrls> <startupUrl>HelloWorldGWT.html</startupUrl> </startupUrls> </configuration> </plugin> <!-- Skip normal test execution, we use gwt:test instead --> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.17</version> <configuration> <skip>true</skip> </configuration> </plugin> </plugins> </build> </project>

From the README.txt that webAppCreator generated:从 webAppCreator 生成的README.txt中:

-- Option D: Using Maven --

If you have generated your project with the option '-maven', you have a 'pom.xml'
file ready to use. Assuming you have Maven installed in your system, 'mvn' is 
in your path, and you have access to maven repositories, you should be able to run:

mvn clean         # delete temporary stuff
mvn test          # run all the tests (gwt and junit)
mvn gwt:devmode   # run development mode (needs "mvn package" to be run before)
mvn package       # generate a .war package ready to deploy

For more information about other available goals, read Maven and gwt-maven-plugin 
documentation (http://maven.apache.org, https://tbroyer.github.io/gwt-maven-plugin/)

so first run mvn package , then mvn run:devmode .所以首先运行mvn package ,然后mvn run:devmode

The website still documents GWT 2.7, not 2.8 (as of September 2016).该网站仍然记录 GWT 2.7,而不是 2.8(截至 2016 年 9 月)。

from the GWT Documentation page you should run mvn gwt:run to bring up the new application in superDevMode.从 GWT 文档 页面,您应该运行mvn gwt:run以在 superDevMode 中启动新应用程序。

UPDATE更新

You have to build your project prior running it.您必须在运行之前构建您的项目。 In other words try:换句话说,尝试:

mvn clean package gwt:devmode

It should work now.它现在应该可以工作了。

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

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