Create and Run Your First ZK Application with Eclipse and Maven

From Documentation
Revision as of 12:16, 25 July 2011 by Jimmyshiau (talk | contribs)

How to create ZK Maven web project

Create Project of Maven

  • [File] -> [New] -> [Other] --> [Maven Project]
    ZK Installation Guide Maven step1.png
  • Make sure Create a simple project is not ticked in the first screen of the New Maven Project wizard and click Next >.
    ZK Installation Guide Maven Archetype step1.png
  • From the Select an Archetype screen, we'll need to add the ZK archetype catalog. Click Configure....
    ZK Installation Guide Maven Archetype step2.png
  • From the Maven archetypes catalogs setting, click Add Remote Catalog... and add the catalog file:
    ZK Installation Guide Maven Archetype step3.png
http://mavensync.zkoss.org/maven2/
  • Click Verify... and then OK to add the catalog.
    • Remote catalog is empty.[1]
  • Click OK in the "Preferences" dialogue.
  • Now you should be able to find zk in the Catalog dropdown list.
    ZK Installation Guide Maven Archetype step4.png
  • Select the zk-archetype-webapp from the list. (At time of writing this is at version 0.8.0).
  • Next, fill in details for group id, artifact id, version number and package name.
    ZK Installation Guide Maven Archetype step5.png
    • Property zk-version-since is missing.[2]
  • Click Finish and the Eclipse status bar should say ' Creating zk-archetype-webapp ' and ' Updating Maven Dependencies '. If this is the first time you deal with ZK libraries, Maven will download the necessary dependencies to compile and run this example, and would be stored in .m2/repository in your home directory.
    ZK Installation Guide Maven Archetype step6.png

  1. If you receive the error message Remote catalog is empty, this is most likely due to a bug in the m2eclipse plugin in v0.12.x, MNGECLIPSE-2757. Until m2eclipse 0.13.x or newer are released, there are two possible workarounds:
    1. Install the "Older version" 0.10.x from the Installing m2eclipse website. You'll need to first uninstall m2eclipse 0.12.x, restart and then install 0.10.x from these install sites:
      http://m2eclipse.sonatype.org/sites/m2e/0.10.2.20100623-1649/
    2. Create the plugin from the archetype using the Maven command line tool mvn, then use Import existing maven project to add the generated project to Eclipse.
  2. The first time you run this wizard, m2eclipse will not yet have downloaded the zk archetype, and might not populate the zk-version-since property correctly, leading to an error message like:
    • Unable to create project from archetype [org.zkoss:zk-archetype-webapp:0.8.0 -> http://mavensync.zkoss.org/maven2/], Archetype org.zkoss:zk-archetype-webapp:0.8.0 is not configured Property zk-version-since is missing.
    The simple workaround is to just try again - this time the zk-version-since property should appear in the list. If it is still missing - add it with the value Example and try again.

How to run Maven project on Run-Jetty-Run