我遵循这个答案(感谢Ed),发现他还没有完全解决问题。
我已经启动并运行了SuperDevMode/CodeServer,但它不包括我的html文件,这使得它有点无用。 我真的需要运行 2 台 Web 服务器吗?
我正在使用 Gradle,如果这很重要的话。
如果你在服务器端没有任何内容,那么你可以简单地将你的HTML主机页面放在你的公共路径中,而不是在war文件夹中,然后它将由SuperDevMode CodeServer提供,因为它现在是模块的一部分。不要忘记调整您的<script>
:*.nocache.js
将是页面的同级。
这是我得出的答案。 在我的 HTML 文件中,我删除了加载 *.nocache 的脚本.js而是动态生成它,如下所示:
<script type="text/javascript">
function loadScript(scriptSrc)
{
var scriptTag = document.createElement('script');
scriptTag.type = 'text/javascript';
scriptTag.async = true;
scriptTag.src = scriptSrc;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(scriptTag, s);
}
// Load the GWT script
loadScript(('file:' == document.location.protocol ? "http://localhost:9876/" : "") + "admin/admin.nocache.js");
</script>
我用于运行代码服务器的 Gradle 任务如下所示:
task codeServer(dependsOn: "war") << {
println("*----------------------------------------------------------------------------------------------*")
println(" Ignore what this says below about going to http://localhost:9876/")
println(" Instead, once the server below is up, in a separate command line, type:")
println(" start $buildDir\exploded\Admin.html")
println("*----------------------------------------------------------------------------------------------*")
def gwtTempDir = "$buildDir/gwtTemp"
(new File(gwtTempDir)).mkdirs()
ant.java(classname: "com.google.gwt.dev.codeserver.CodeServer", failonerror: "true", fork: "true") {
classpath {
pathElement(location: "src/main/java")
pathElement(location: "src/main/resources")
pathElement(location: "$buildDir/classes/main")
pathElement(path: configurations.compile.asPath)
}
jvmarg(value: "-Xmx512m")
sysproperty(key: "java.util.logging.SimpleFormatter.format", value: System.getProperty("java.util.logging.SimpleFormatter.format"));
arg(line: "-workDir " + gwtTempDir)
arg(line: "-src " + "src/main/java")
arg(value: "com.onlyinsight.oventio.Admin")
}
}
所以现在,我可以将浏览器指向 file:///F:/projects/ConferenceModule/build/exploded/Admin.html,而不是拥有第二个网络服务器,一切正常。
我希望这对其他人有所帮助。