Spring and Wicket work great together, and using Spring Beans in Wicket is just one small example. Here is how easy it is to use a Spring Bean in Wicket.
We begin in the WicketApplication class which serves as Spring’s starting point by using Spring Boot’s @EnableAutoConfiguration annotation and providing a main() method. In the WicketApplication init() method we’re making wicket pages injectable by activating the SpringComponentInjector with Spring’s ApplicationContext.
We create our Spring Context using Spring Annotations in a class named SpringConfiguration.
Now we can move to our (very simple) TextService class, annotated with @Service. We’ll be returning “delivered by spring service” to our Wicket page next.
In our Wicket page class we instantiate our TextService with @SpringBean (Wicket’s @AutoWired equivalent) and display getText() in our Wicket label.
Which displays on the page as you see, “delivered by spring service…”