In this recipe, you'll learn how to install Spring Mobile and prepare the Spring configuration class for the other recipes.
Here are the steps to install Spring Mobile:
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>
Make the Spring configuration class extend
WebMvcConfigurerAdapter
:@Configuration @EnableWebMvc @ComponentScan(basePackages = {"com.spring_cookbook.controllers"}) public class AppConfig extends WebMvcConfigurerAdapter {
Override the
addInterceptors()
method fromWebMvcConfigurerAdapter
:@Override public void addInterceptors(InterceptorRegistry registry) { }
The addInterceptors()
method will be used in the following recipes to register various interceptors.