GWT不加载*.nocache.js
我用gwt Maven原型构建了这个Maven项目。虽然它与GWT不加载*.nocache.js,gwt,maven,tomcat7,gwt-maven-plugin,Gwt,Maven,Tomcat7,Gwt Maven Plugin,我用gwt Maven原型构建了这个Maven项目。虽然它与mvn-gwt:run目标完美地运行,但是当我尝试在tomcat7容器中运行它时,无论是mvn-tomcat:run还是mvn-gwt:compile&&mvn-tomcat:run它都不会加载gwt动态创建的小部件 根据Google Chrome控制台,它找不到*.nocache.js文件,即使在/target/文件夹中,它也正好位于预期的位置 我目前正在尝试在入口点模块中显示一个简单的“Hello”标签: GWT入口点 *.html
mvn-gwt:run
目标完美地运行,但是当我尝试在tomcat7容器中运行它时,无论是mvn-tomcat:run
还是mvn-gwt:compile&&mvn-tomcat:run
它都不会加载gwt动态创建的小部件
根据Google Chrome控制台,它找不到*.nocache.js
文件,即使在/target/
文件夹中,它也正好位于预期的位置
我目前正在尝试在入口点模块中显示一个简单的“Hello”标签:
GWT入口点
*.html
Web应用程序启动程序项目
您的web浏览器必须启用JavaScript
以使此应用程序正确显示。
POM.XML
4.0.0
韦尔蒂斯托酒店
网状物
战争
1.0-快照
GWT Maven原型
2.4.0
${project.build.directory}/${project.build.finalName}
UTF-8
com.google.gwt
gwt servlet
${gwtVersion}
运行时
com.google.gwt
gwt用户
${gwtVersion}
假如
朱尼特
朱尼特
4.7
测试
javax.validation
验证api
1.0.0.GA
测试
javax.validation
验证api
1.0.0.GA
来源
测试
com.github.gwtbootstrap
gwt引导
2.0.4.0
${webappDirectory}/WEB-INF/classes
org.apache.maven.plugins
maven战争插件
2.1.1
编译
爆炸了的
${webappDirectory}
org.apache.maven.plugins
maven编译器插件
2.3.2
1.5
1.5
org.apache.tomcat.maven
tomcat7 maven插件
2
/天鹅绒
org.codehaus.mojo
GWTMaven插件
2.4.0
编译
veltisto.html
${webappDirectory}
*.GWT.XML
使用firebug或chrome的inspector,您是否看到
.nocache.js
和.cache.html
文件加载正确?还是有类似404的错误?如果有404,请查看war目录中错误指定的路径-文件在那里吗
如果.nocache.js
文件丢失或位于错误的位置,则可能意味着从您列出的*.html
页面到已编译js的路径错误
如果缺少.cache.html
文件,则通常意味着gwt:compile被跳过,或者gwt:run或gwt:debug在编译期间或之后运行。不要在执行gwt:compile
之后再执行gwt:run
或:debug:
,因为后两项将删除已编译的文件
最后一个想法是:
tomcat:run
阶段可能试图获取一个完整的.war
文件,而您的war:exploded
不会创建一个。此外,当您运行gwt:compile
时,这可能不会导致生成已编译的完整war目录。要处理所有这些问题,请考虑让构建工作先生成一个WAR文件,然后尝试创建<代码> Tomcat:运行< /Comp>行为。这里的第一步是将gwt:compile
映射到prepare package
阶段,然后确保完成的war包含.nocache.js
和.cache.html
文件,如预期的那样。tomcat7:run
只使用src/main/webapp
。您将需要使用tomcat7:runwar
(这将执行package
)或tomcat7:runwar only
(如果您已经有war:explodesd
结构)。尝试将“maven-war插件”的阶段从“编译”改为“打包”,它实际上只适用于tomcat:runwar。当我指定目标tomcat7:runwar
时,它仍然没有加载.nocache.js
顺便说一句,tomcat:
前缀使用了org.codehaus.mojo:tomcat maven插件
,其最新发布时间为2年。该项目现在已经转移到ApacheTomcat项目,并分为tomcat6 maven插件
和tomcat7 maven插件
(您使用),分别带有前缀tomcat6:
和tomcat7:
前缀。使用tomcat:run
您的tomcat7 maven插件
配置(/veltisto
)将不会被使用。同样,mvn jetty:run war
也为我解决了这个问题。
public class Hello implements EntryPoint {
public void onModuleLoad() {
Label hello = new Label("TESTESTSTSTS");
RootPanel.get("helloContainer").add(hello);
}
}
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="veltisto.css">
<title>Web Application Starter Project</title>
<script type="text/javascript" language="javascript" src="veltisto/veltisto.nocache.js"></script>
</head>
<body>
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
<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>
<div id="helloContainer"></div>
</body>
</html>
<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>gr.veltisto</groupId>
<artifactId>web</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>GWT Maven Archetype</name>
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.4.0</gwtVersion>
<!-- GWT needs at least java 1.5 -->
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwtVersion}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<classifier>sources</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.gwtbootstrap</groupId>
<artifactId>gwt-bootstrap</artifactId>
<version>2.0.4.0</version>
</dependency>
</dependencies>
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<plugins>
<!-- Copy static web files before executing gwt:run -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<path>/veltisto</path>
</configuration>
</plugin>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options,
see gwt-maven-plugin documentation at codehaus.org -->
<configuration>
<runTarget>veltisto.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
</configuration>
</plugin>
</plugins>
</build>
</project>
<module rename-to='veltisto'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<inherits name="com.google.gwt.uibinder.UiBinder" />
<!-- We need the JUnit module in the main module, -->
<!-- otherwise eclipse complains (Google plugin bug?) -->
<inherits name='com.google.gwt.junit.JUnit' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<inherits name="com.google.gwt.uibinder.UiBinder" />
<inherits name="com.github.gwtbootstrap.Bootstrap" />
<!-- Specify the app entry point class. -->
<entry-point class='gr.veltisto.web.client.Hello' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
</module>