Book Image

Spring Cookbook

Book Image

Spring Cookbook

Overview of this book

Table of Contents (19 chapters)
Spring Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
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...