我跟着this answer(謝謝埃德),發現他還沒有完全解決這個問題。如何讓GWT超級開發模式/ SuperDevMode包含我的html文件?
我已經啓動了SuperDevMode/CodeServer並運行,但它沒有包含我的html文件,這使得它沒用。我真的需要運行2個Web服務器嗎?
我使用Gradle,如果這很重要的話。
我跟着this answer(謝謝埃德),發現他還沒有完全解決這個問題。如何讓GWT超級開發模式/ SuperDevMode包含我的html文件?
我已經啓動了SuperDevMode/CodeServer並運行,但它沒有包含我的html文件,這使得它沒用。我真的需要運行2個Web服務器嗎?
我使用Gradle,如果這很重要的話。
這是我想出的答案。在我的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>
我的搖籃任務運行的代碼服務器看起來是這樣的:
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,而不是使用第二個Web服務器,並且它可以工作。
我希望能幫助別人。
如果你沒有什麼服務器端,那麼你可以簡單地把你的HTML主頁在public path而不是war文件夾內,它會接着由SuperDevMode CodeServer擔任,因爲它是現在模塊的一部分。不要忘記調整你的<script>
:*.nocache.js
將成爲頁面的兄弟姐妹。
真棒建議。我沒有想到這一點。事實上,我可以將其餘的服務器端的東西(圖片,html)放在該公共路徑中,然後代碼服務器將工作得更好。 我真的放棄了這個項目,玩了大約4個小時後。我的超級開發模式仍然有點不成熟。花了23s編譯我的模塊,每次代碼更改後我都需要等待。這足以維持目前5-10秒的等待開發模式,使其成爲一個交易殺手。 –
通過_anything服務器端_,我在說_code_:圖像不是_something服務器端_。至於SuperDevMode的性能,確實有改進的餘地:發生器必須支持遞增運行(緩存結果而不是每次重新生成),現在只有RPC和ClientBundle可以執行:不是UiBinder,不是編輯器,不是RequestFactory等等這些會減慢編譯速度。在以後的版本中會有更好的表現。 SuperDevMode被標記爲_experimental_ ;-)是有原因的 –