Simple example of using Spring Security 4 with Spring Boot 1.2.x with Maven.
The key is to use the Spring Security Starter and override the spring-security.version property. For example:
<properties>
<!-- ... -->
<spring-security.version>4.0.1.RELEASE</spring-security.version>
</properties>
<dependencies>
<!-- ... -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
If you are migrating from Spring Security 3.2.x, then the same migration steps are involved as a standard Spring Security 3.2.x to Spring Security 4.x migration.
If you are using Thymeleaf, then you need to ensure to use
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
then you need to expose the SpringSecurityDialect
as a @Bean
import org.springframework.context.annotation.*;
import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect;
@Configuration
public class SecurityConfig {
@Bean
public SpringSecurityDialect securityDialect() {
return new SpringSecurityDialect();
}
}