Setting Up ZK Spring using Maven"

From Documentation
 
(8 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
= Create a New Project with ZK Archetype =
 
= 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.
+
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 [[ZK Installation Guide/Quick Start/Create and Run Your First ZK Application with Eclipse and Maven#Use the command line version of Maven to create a project]].
+
If you use maven in a command line console, you need to specify ZK archetype catalog URL to generate your project. Please refer to [[ZK Installation Guide/Quick Start/Create and Run Your First ZK Application with Eclipse and Maven#Create_a_Maven_Project_with_a_Command_Line_Interface | 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]]
 
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]]
Line 11: Line 11:
 
= Adding ZK Spring Dependencies  =
 
= 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 upon your requirement.
+
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 '''5''', you can use '''3.0''' or above.
  
For ZK '''6''' or above, you should use '''3.1''' or above.
+
For ZK '''6+''' '''3.2'''
  
'''Required for 3 modules'''
+
For ZK '''8+''' or above, you should use '''4.0.0''' or above.
 +
 
 +
'''Required for both modules'''
 
<source lang='xml'>
 
<source lang='xml'>
 
<dependency>
 
<dependency>
Line 32: Line 34:
 
<groupId>org.zkoss.zk</groupId>
 
<groupId>org.zkoss.zk</groupId>
 
<artifactId>zkspring-core</artifactId>
 
<artifactId>zkspring-core</artifactId>
<version>3.1.1</version>
+
<version>${zkspring.version}</version>
 
</dependency>
 
</dependency>
 
 
</source>
 
</source>
 +
Check the available versions at [https://mavensync.zkoss.org/maven2/org/zkoss/zk/zkspring-core/ CE repository].
  
 
'''ZK Spring Security'''
 
'''ZK Spring Security'''
Line 42: Line 44:
 
<groupId>org.zkoss.zk</groupId>
 
<groupId>org.zkoss.zk</groupId>
 
<artifactId>zkspring-security</artifactId>
 
<artifactId>zkspring-security</artifactId>
<version>3.1.1</version>
+
<version>${zkspring.version}</version>
 
</dependency>
 
</dependency>
 +
</source>
 +
Check the available versions at [https://mavensync.zkoss.org/maven2/org/zkoss/zk/zkspring-security/ CE repository]
 +
  
</source>
+
'''ZK Spring Webflow'''
 +
 
 +
discontinued since 4.0.0
 +
 
 +
==ZKSpring 6 ==
 +
Notice that this version depends on [https://spring.io/blog/2022/11/16/spring-framework-6-0-goes-ga Spring Framework 6.0] and requires Jakarta EE.
  
 
= Configuration in web.xml =
 
= Configuration in web.xml =
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.  
+
You need to declare Spring <code>ContextLoaderListener</code> in the <code>web.xml</code> file to be able to declare and register your Spring beans with Spring framework.  
 
<source lang="xml">
 
<source lang="xml">
 
<listener>
 
<listener>
Line 54: Line 64:
 
</listener>
 
</listener>
 
</source>
 
</source>
 +
 +
 +
= Example Project =
 +
* [https://github.com/zkoss/zkspring/tree/master/zkspringessentials/zkspringcoresec zkspring example project for spring 5 or before].
 +
* [https://github.com/zkoss/zkspring/tree/6.0.0/zkspringessentials/zkspringcoresec zkspring example project for spring 6]
  
 
=Version History=
 
=Version History=
{{LastUpdated}}
+
 
 
{| border='1px' | width="100%"
 
{| border='1px' | width="100%"
 
! Version !! Date !! Content
 
! Version !! Date !! Content
Line 63: Line 78:
 
| 2014/10/07
 
| 2014/10/07
 
| rewrite for supported Spring version
 
| rewrite for supported Spring version
 +
|-
 +
| 4.0.0
 +
| 2019/01
 +
| update for 4.0.0
 
|}
 
|}
 
{{ZKSpringEssentialsPageFooter}}
 
{{ZKSpringEssentialsPageFooter}}

Latest revision as of 04:30, 17 January 2024

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

ZKSpring 6

Notice that this version depends on Spring Framework 6.0 and requires Jakarta EE.

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


Last Update : 2024/01/17

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