简体   繁体   中英

How to run GWT in production mode

I am trying to run GWT project in production mode, as per the instructions at https://developers.google.com/web-toolkit/usingeclipse . So my project foo is located as a folder foo in my desktop under th workspace folder. When I right click on the foo project in the Project Explorer, click Google - GWT Compile , I see some message like permutations 1, 2.. etc in the debugging console, after which it says that compilation is complete.

However, contrary to what the Google page says, no additional HTML / Javascript files are generated in the war folder. Also, if I enter foo/war/foo.html in the URL bar, I am getting a timed-out error (even though the page contains only a simple alert call).

Can anyone tell me what is going on here?

If you are running in GWT development mode after the compile

remove the parameter gwt.codesvr=127.0.0.1:9997 in the url given by eclipse

After you compile the code the whole gwt code will convert in to javascript so you can access like an normal HTML page with proper paths .

如果您的GWT项目是Maven项目,并且您正在使用gwt-maven-plugin ,则可以运行mvn jetty:run-war (例如,使用它作为Eclipse Maven运行配置的目标):这将GWT编译您的投射到战争中,并在localhost上运行它,从而运行你的Prod模式。

This can test ui-only features in Production Mode. That's useful if that's all you need to do, especially if otherwise the running of a server for Production Mode occupies limited resources of your development machine that you'd like to save (whereas occupying them with a running server would be a "waste" if your testing doesn't need to make requests to that server anyways).

If your GWT project...

  1. doesn't make any server requests for data yet (maybe your project is still in its infancy as well), and...
  2. is a Maven project

... you can...

  1. GWT compile your project
  2. Maven package (those directions use gwt-Eclipse-maven-plugin ) your project
  3. open the packaged GWT host page (ie: index.html, or < Your Module >.html, under yourProject/target/yourProject-< snapshot version >/) in a browser. Profit!

This is sufficient to test the project's ui-only features, thus in Production Mode. In fact, if your project has features that make server requests for data, but you aren't testing any of them, then this will still work to test just those ui-only features. Basically, any features requesting server data will not have those requests returned (as there is no server running to do that), but all other features will function, as they are ui-only.

If you need to test features that make server requests for data, then you'll have to run Production Mode via a server (that would respond to the requests). For example with Jetty server, see my other Answer here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM