Enabling Spring Security
To enable Spring Security, you need to add some Maven dependencies. You also need to create some configuration classes.
How to do it…
Here are the steps to enable Spring Security:
- Add the Maven dependencies for Spring Security in
pom.xml
. Note that the version number is different from Spring Core:<dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>3.2.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>3.2.5.RELEASE</version> </dependency>
- Create a class for the Spring Security configuration:
@Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { }
- Declare the configuration class in the
ServletInitializer
class:public class...