使用gwt-maven-plugin编译后,Javascript文件丢失了

时间:2015-11-22 14:18:33

标签: maven gwt gwt-maven-plugin

您好我尝试创建一个由gwt-maven-plugin编译的基本GWT应用程序。

当我打开已编译的应用程序时,我在浏览器控制台上收到错误:

gwt_me.nocache.js:10 GET http://localhost:8080/gwt_me-0.0.1-SNAPSHOT/gwt_me/A1CD3F6399B6C09915737534046387C0.cache.js 

这些文件是在编译后生成的:

Files generated after compilation

的pom.xml

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>gwt_me</groupId>
    <artifactId>gwt_me</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>gwt.me</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <repositories>
        <repository>
            <id>Codehaus Mojo</id>
            <name>Codehaus Mojo</name>
            <url>https://nexus.codehaus.org/content/repositories/releases/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <version>2.7.0</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>2.7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.errai</groupId>
            <artifactId>errai-bus</artifactId>
            <version>3.2.0.Final</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>2.7.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>generateAsync</goal>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

gwtMe.gwt.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN"
  "http://google-web-toolkit.googlecode.com/svn/tags/2.7.0/distro-source/core/src/gwt-module.dtd">

<module rename-to='gwt_me'>
  <inherits name='com.google.gwt.user.User'/>
  <inherits name='com.google.gwt.user.theme.standard.Standard'/>
  <inherits name="com.google.gwt.activity.Activity"/>
  <inherits name='org.jboss.errai.bus.ErraiBus' />

  <!-- Specify the app entry point class.                         -->
  <entry-point class='gwt.user.client.ClientService'/>

</module>

gwt_me.html

<!doctype html>

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link type="text/css" rel="stylesheet" href="gwt_me.css">
    <title>gwt_me</title>
    <script type="text/javascript" language="javascript" src="gwt_me/gwt_me.nocache.js"></script>
  </head>

  <body>

    <!-- OPTIONAL: include this if you want history support -->
    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>

    <!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
    <noscript>
      <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
        Your web browser must have JavaScript enabled
        in order for this application to display correctly.
      </div>
    </noscript>

    <h1>Web Application Starter Project</h1>

    <table align="center">
      <tr>
        <td colspan="2" style="font-weight:bold;">Please enter your name:</td>        
      </tr>
      <tr>
        <td id="nameFieldContainer"></td>
        <td id="sendButtonContainer"></td>
      </tr>
      <tr>
        <td colspan="2" style="color:red;" id="errorLabelContainer"></td>
      </tr>
    </table>
  </body>
</html>

Maven控制台输出

[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building gwt.me 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- gwt-maven-plugin:2.7.0:generateAsync (default) @ gwt_me ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ gwt_me ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ gwt_me ---
[INFO] Compiling 1 source file to /Users/and/devel/eclipse-projects/gwt_me/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ gwt_me ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ gwt_me ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ gwt_me ---
[INFO] 
[INFO] --- gwt-maven-plugin:2.7.0:compile (default) @ gwt_me ---
[INFO] auto discovered modules [gwt.user.gwtErraiMessaging]
[INFO] Compiling module gwt.user.gwtErraiMessaging
[ERROR] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[ERROR] SLF4J: Defaulting to no-operation (NOP) logger implementation
[ERROR] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO]    Computing all possible rebind results for 'org.jboss.errai.marshalling.client.api.MarshallerFactory'
[INFO]       Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory
[INFO]          Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator
[INFO]             Generating Marshallers Bootstrapper...
[INFO]       Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory
[INFO]          Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator
[INFO]             Generating Marshallers Bootstrapper...
[INFO]       Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory
[INFO]          Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator
[INFO]             Generating Marshallers Bootstrapper...
[INFO]       Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory
[INFO]          Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator
[INFO]             Generating Marshallers Bootstrapper...
[INFO]       Rebinding org.jboss.errai.marshalling.client.api.MarshallerFactory
[INFO]          Invoking generator org.jboss.errai.marshalling.rebind.MarshallersGenerator
[INFO]             Generating Marshallers Bootstrapper...
[INFO]    Compiling 5 permutations
[INFO]       Compiling permutation 0...
[INFO]       Process output
[INFO]          Compiling
[INFO]             Compiling permutation 1...
[INFO]       Process output
[INFO]          Compiling
[INFO]             Compiling permutation 3...
[INFO]       Process output
[INFO]          Compiling
[INFO]             Compiling permutation 2...
[INFO]       Compiling permutation 4...
[INFO]    Compile of permutations succeeded
[INFO]    Compilation succeeded -- 45,514s
[INFO] Linking into /Users/and/devel/eclipse-projects/gwt_me/target/gwt_me-0.0.1-SNAPSHOT/gwt_me
[INFO]    Link succeeded
[INFO]    Linking succeeded -- 0,574s
[INFO] 
[INFO] --- maven-war-plugin:2.2:war (default-war) @ gwt_me ---
[INFO] Packaging webapp
[INFO] Assembling webapp [gwt_me] in [/Users/and/devel/eclipse-projects/gwt_me/target/gwt_me-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/and/devel/eclipse-projects/gwt_me/src/main/webapp]
[INFO] Webapp assembled in [167 msecs]
[INFO] Building war: /Users/and/devel/eclipse-projects/gwt_me/target/gwt_me-0.0.1-SNAPSHOT.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 56.046 s
[INFO] Finished at: 2015-11-22T14:47:54+01:00
[INFO] Final Memory: 29M/285M
[INFO] ------------------------------------------------------------------------

1 个答案:

答案 0 :(得分:2)

这通常是由浏览器缓存的...nocache.js引起的。

在大多数浏览器中,按 control-shift-R 会重新加载页面和所有CSS / JavaScript资源。