2016-09-28 78 views
3
工作

我已經創造了在這條路上Maven配置GWT項目:與WebAppCreator作出GWT Maven項目不DEVMODE

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

我試圖在DEVMODE運行項目:

mvn gwt:devmode 

但在瀏覽器中,我得到:

"HTTP ERROR 404 

Problem accessing /HelloWorldGWT.html. 

Reason: Not Found" 

我看了一下,WEB-INF目錄是空的。

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>

回答

3

從GWT文檔page你應該運行mvn gwt:run,彈出superDevMode新的應用程序。

UPDATE

你必須建立你的項目之前運行它。換句話說嘗試:

mvn clean package gwt:devmode

應該現在的工作。

+0

mvn gwt:運行不工作: [錯誤]無法在插件中找到目標'運行'net.ltgt.gwt.maven:gwt-maven-plugin:1.0-rc-6可用目標之中add-super -sources,add-test-super-sou s,codeserver,compile,devmode,enforce-encoding,generate-module,generate-module-metadata,help,import-sources,import-test-sources,package-app est - > [Help 1] –

+0

@VitVyaz是的你是對的,似乎他們在他們的網站有錯誤。我正在看它,如果我找到解決方案,我會更新我的答案。抱歉給你帶來不便。 – pleft

+0

@VitVyaz我想我找到了,請檢查我的更新回答 – pleft

3

從這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/) 

所以第一次運行mvn package,然後mvn run:devmode

該網站仍然記錄GWT 2.7,而不是2.8(截至2016年9月)。