Over a million developers have joined DZone.

Enhance Wicket With Spring Boot

DZone's Guide to

Enhance Wicket With Spring Boot

Wicket is a good framework, but its configuration code is verbose. Fortunately, you can integrate it with Spring Boot to take advantage of its autoconfigure capabilities.

· Java Zone
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

Wicket has traditionally provided a solid integration with the core part of Spring (i.e. the container) with its dedicated module wicket-spring. Recently, a new independent project called wicket-spring-boot has extended Spring integration to Spring Boot, too. With it, we can use Spring Boot as application starter and take advantage of its autoconfigure capabilities to set up the entire application.

To run a Wicket application with Spring Boot, we must first include the following dependency (for Maven) in our project:


Now, to run a Wicket application, we can implement a starter class like we used to do with Spring Boot:

public class BootApp {

    public static void main(String[] args) throws Exception {

        new SpringApplicationBuilder()

In addition to this class, we should also specify the home page of our application by applying the annotation @WicketHomePage (the page class must be in the same application package or in a subpackage):

public class HomePage extends WebPage {
    //...page code

If we run the BootApp class, we will see our home page at http://localhost:8080. As we can see, there's no trace of the Wicket application class where we override the init method to set up our web application. For this purpose, we can use the extension class WicketApplicationInitConfiguration:

public class YouExtensionConfig implements WicketApplicationInitConfiguration {

  public void init(WebApplication webApplication) {

      //...config stuff

In this class, we can also override the getHomePage() method if we don't want to use @WicketHomePage. If this class is not enough to configure our application, we can use WicketBootStandardWebApplication or WicketBootSecuredWebApplication (this last one is for secured applications).

To distribute our application as an executable JAR, we can simply use the Spring Boot Maven plugin:


Simplify Configuration With Spring Boot

During its lifetime, Wicket has seen a growing number of satellite projects aimed at extending the core framework. Most of them are hosted at WicketStuff. The configuration code for Wicket and its extensions tends to be very verbose and hard to read and mantain. With Spring Boot, we can get rid of all this code and use a simple YAML file to configure our application.

By default, Wicket Spring Boot Starter comes with a default YML configuration file for a 'development' Spring profile that can be overriden with a custom application-development.yml (under  'src/main/resources' ). Here is an example of a generic YML configuration file:

wicket.core.settings.general.configuration-type=development # development/deployment(default)

#Markup - Settings

#CSRF prevention
wicket.core.csrf.error-message=Origin does not correspond to request

#datastore settings

Beside core parameters wicket-spring-boot also supports configuration for a number of WicketStuff modules:

#configure REST resources with restannotations
wicket.stuff.restannotations.packagename= # the package name to scan for project specific annotations

#use fast 2 as serialization library

#use html compressor

As you can see, with wicket-spring-boot, the integration between Wicket and Spring Boot is really straightforward! For more configuration options, you can see the project homepage on GitHub.

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

java ,apache wicket ,spring boot ,tutorial ,java ee

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}