Book Image

SPRING COOKBOOK

By : Jerome Jaglale, Yilmaz
Book Image

SPRING COOKBOOK

By: Jerome Jaglale, Yilmaz

Overview of this book

This book is for you if you have some experience with Java and web development (not necessarily in Java) and want to become proficient quickly with Spring.
Table of Contents (14 chapters)
13
Index

Installing Spring Mobile


In this recipe, you'll learn how to install Spring Mobile and prepare the Spring configuration class for the other recipes.

How to do it…

Here are the steps to install Spring Mobile:

  1. Add the Maven dependency for Spring Mobile in pom.xml:

    <dependency>
      <groupId>org.springframework.mobile</groupId>
      <artifactId>spring-mobile-device</artifactId>
      <version>1.1.3.RELEASE</version>
    </dependency>
  2. Make the Spring configuration class extend WebMvcConfigurerAdapter:

    @Configuration
    @EnableWebMvc
    @ComponentScan(basePackages = {"com.spring_cookbook.controllers"})
    public class AppConfig extends WebMvcConfigurerAdapter {
  3. Override the addInterceptors() method from WebMvcConfigurerAdapter:

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    }

How it works…

The addInterceptors() method will be used in the following recipes to register various interceptors.

There's more…

For more information about interceptors, refer to the...