Setting Up ZK Spring using Maven"

From Documentation
(→‎Adding ZK Spring library dependencies: remove jboss.el , zk version with zkspring version)
(rewrite for supported Spring version)
Line 1: Line 1:
 
{{ZKSpringEssentialsPageHeader}}
 
{{ZKSpringEssentialsPageHeader}}
{{ZKSpringEssentialsHeadingToc}}
 
  
===Purpose===
+
= Create a New Project with ZK Archetype =
Setup ZK Spring Integration Library using maven configurations
 
  
===Example===
+
The simplest way to create a ZK maven project is using archetype: '''zk-ee-eval-archetype-webapp-spring'''. A project generated by this archetype will include required ZK and spring dependencies and ZK maven evaluation repository.
  
==== Add ZK Maven repository to your pom.xml file ====
+
If you use maven in a console, you need to specify ZK archetype catalog URL, http://mavensync.zkoss.org/eval/archetype-catalog.xml, to generate your project. Please refer to [http://maven.apache.org/archetype/maven-archetype-plugin/examples/generate-alternative-catalog.html Generate project using an alternative catalog].
By default, while resolving project dependencies Maven will only look into Maven central repository [http://repo1.maven.org/maven2]. In order to use ZK Maven repository, add the following <repositories> elements into pom.xml under the root <project> element.
 
  
<source lang="xml">
+
If you use eclipse, you can add the catalog URL via Window / Preferences / Maven / Archetypes.
<repositories>
+
[[File:eclipse-archetypes.png | center]]
    <repository>
+
 
      <id>zk repository</id>
+
Then select File / New / Other / Maven Project to create a maven project.
      <url>http://mavensync.zkoss.org/maven2</url>
 
    </repository>
 
  </repositories>
 
</source>
 
  
Note that ZK Maven repository URL is [http://mavensync.zkoss.org/maven2 http://mavensync.zkoss.org/maven2].
 
  
==== Adding ZK Spring library dependencies ====
+
= Adding ZK Spring Dependencies =
  
Add the following dependencies and Maven can resolve them by connecting to [http://mavensync.zkoss.org/maven2 ZK Maven repository].
+
After creating a project, you still need to add ZK Spring dependencies. ZK Spring has 3 artifacts, you can add them upon your requirement.
  
For ZK '''5''', you can use '''3.0''' or '''3.1'''.
+
For ZK '''5''', you can use '''3.0''' or above.
  
For ZK '''6''', you should use '''3.1'''.
+
For ZK '''6''' or above, you should use '''3.1''' or above.
  
'''ZK Spring Core''''
+
'''ZK Spring Core'''
 
<source lang="xml">
 
<source lang="xml">
  
Line 35: Line 27:
 
<groupId>org.zkoss.zk</groupId>
 
<groupId>org.zkoss.zk</groupId>
 
<artifactId>zkspring-core</artifactId>
 
<artifactId>zkspring-core</artifactId>
<version>3.1</version>
+
<version>3.1.1</version>
 
</dependency>
 
</dependency>
  
 
</source>
 
</source>
 
You can add zkspring-webflow or zkspring-security according to your requirement.
 
  
 
'''ZK Spring Webflow'''
 
'''ZK Spring Webflow'''
Line 47: Line 37:
 
<groupId>org.zkoss.zk</groupId>
 
<groupId>org.zkoss.zk</groupId>
 
<artifactId>zkspring-webflow</artifactId>
 
<artifactId>zkspring-webflow</artifactId>
<version>3.1</version>
+
<version>3.1.1</version>
 
</dependency>
 
</dependency>
  
Line 57: Line 47:
 
<groupId>org.zkoss.zk</groupId>
 
<groupId>org.zkoss.zk</groupId>
 
<artifactId>zkspring-security</artifactId>
 
<artifactId>zkspring-security</artifactId>
<version>3.1</version>
+
<version>3.1.1</version>
 
</dependency>
 
</dependency>
  
 
</source>
 
</source>
  
===Configuration===
+
= Configuration in web.xml =
* You need to declare Spring ContextLoaderListener in the web.xml file to be able to declare and register your Spring beans with Spring framework.  
+
You need to declare Spring <tt>ContextLoaderListener</tt> in the <tt>web.xml</tt> file to be able to declare and register your Spring beans with Spring framework.  
 
<source lang="xml">
 
<source lang="xml">
 
<listener>
 
<listener>
Line 75: Line 65:
 
! Version !! Date !! Content
 
! Version !! Date !! Content
 
|-
 
|-
| &nbsp;
+
| 3.1.1
| &nbsp;
+
| 2014/10/07
| &nbsp;
+
| rewrite for supported Spring version
 
|}
 
|}
 
{{ZKSpringEssentialsPageFooter}}
 
{{ZKSpringEssentialsPageFooter}}

Revision as of 07:43, 7 October 2014

Setting Up ZK Spring using Maven



Create a New Project with ZK Archetype

The simplest way to create a ZK maven project is using archetype: zk-ee-eval-archetype-webapp-spring. A project generated by this archetype will include required ZK and spring dependencies and ZK maven evaluation repository.

If you use maven in a console, you need to specify ZK archetype catalog URL, http://mavensync.zkoss.org/eval/archetype-catalog.xml, to generate your project. Please refer to Generate project using an alternative catalog.

If you use eclipse, you can add the catalog URL via Window / Preferences / Maven / Archetypes.

Eclipse-archetypes.png

Then select File / New / Other / Maven Project to create a maven project.


Adding ZK Spring Dependencies

After creating a project, you still need to add ZK Spring dependencies. ZK Spring has 3 artifacts, you can add them upon your requirement.

For ZK 5, you can use 3.0 or above.

For ZK 6 or above, you should use 3.1 or above.

ZK Spring Core

<dependency>
	<groupId>org.zkoss.zk</groupId>
	<artifactId>zkspring-core</artifactId>
	<version>3.1.1</version>
</dependency>

ZK Spring Webflow

<dependency>
	<groupId>org.zkoss.zk</groupId>
	<artifactId>zkspring-webflow</artifactId>
	<version>3.1.1</version>
</dependency>

ZK Spring Security

<dependency>
	<groupId>org.zkoss.zk</groupId>
	<artifactId>zkspring-security</artifactId>
	<version>3.1.1</version>
</dependency>

Configuration in web.xml

You need to declare Spring ContextLoaderListener in the web.xml file to be able to declare and register your Spring beans with Spring framework.

<listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

Version History

Last Update : 2014/10/07


Version Date Content
3.1.1 2014/10/07 rewrite for supported Spring version


Last Update : 2014/10/07

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.