Setting Up ZK Spring using Maven
Create a New Project with ZK Archetype
The simplest way to create a ZK maven project is using the 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 command line console, you need to specify ZK archetype catalog URL to generate your project. Please refer to Create a Maven Project with a Command Line Interface.
If you use eclipse, you can add the catalog URL via Window / Preferences / Maven / Archetypes, please refer to ZK Installation Guide/Quick Start/Create and Run Your First ZK Application with Eclipse and Maven#Add ZK Maven Archetype
Adding ZK Spring Dependencies
After creating a project, you still need to add ZK Spring dependencies. ZK Spring has 2 artifacts, you can add them to your requirement.
For ZK 5, you can use 3.0 or above.
For ZK 6+ 3.2
For ZK 8+ or above, you should use 4.0.0 or above.
Required for both modules
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkplus</artifactId>
<version>${zk.version}</version>
</dependency>
ZK Spring Core
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkspring-core</artifactId>
<version>${zkspring.version}</version>
</dependency>
Check the available versions at CE repository.
ZK Spring Security
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkspring-security</artifactId>
<version>${zkspring.version}</version>
</dependency>
Check the available versions at CE repository
ZK Spring Webflow
discontinued since 4.0.0
ZK Spring 6
Notice that this version depends on Spring Framework 6.0 and requires Jakarta EE.
Adding Spring Dependencies
ZK Spring does not enforce a specific Spring Framework or Spring Security version. Since projects may require different Spring versions, developers are responsible for explicitly adding the Spring dependencies they need (for example, spring-web, spring-security-web) to their project.
ZK may provide optional default dependency versions for reference or convenience. These versions are not mandatory and may not always reflect the latest Spring or Spring Security releases due to compatibility testing or environment considerations. Users are free to override these defaults and use any supported version that meets their project or security requirements.
In general, ZK Spring is compatible with the same major version of the Spring Framework. For example, ZK Spring 6.x is compatible with Spring Framework 6.x. Therefore, if a security issue is identified in a specific Spring Security version (e.g., spring-security-core 6.4.2), users can safely upgrade to a newer compatible version (e.g., 6.5.6) without requiring changes to ZK Spring.
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>
Example Project
Version History
| Version | Date | Content |
|---|---|---|
| 3.1.1 | 2014/10/07 | rewrite for supported Spring version |
| 4.0.0 | 2019/01 | update for 4.0.0 |