2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								[[getting]]
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[[getting-gradle]]
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								= Getting Spring Security
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 16:01:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								This section describes how to get the Spring Security binaries.
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 15:21:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								See xref:community.adoc#community-source[Source Code] for how to obtain the source code.
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								== Release Numbering
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Spring Security versions are formatted as MAJOR.MINOR.PATCH such that:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								* MAJOR versions may contain breaking changes.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Typically, these are done to provide improved security to match modern security practices.
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 16:01:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								* MINOR versions contain enhancements but are considered passive updates.
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								* PATCH level should be perfectly compatible, forwards and backwards, with the possible exception of changes that fix bugs.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[[maven]]
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								== Usage
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								As most open source projects, Spring Security deploys its dependencies as Maven artifacts, which makes them compatible with both Maven and Gradle. The following sections demonstrate how to integrate Spring Security with these build tools, with examples for Spring Boot and standalone usage.
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[[getting-maven-boot]]
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[[getting-gradle-boot]]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								=== Spring Boot
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 16:01:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Spring Boot provides a `spring-boot-starter-security` starter that aggregates Spring Security-related dependencies.
							 
						 
					
						
							
								
									
										
										
										
											2023-12-26 14:05:39 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The simplest and preferred way to use the starter is to use https://docs.spring.io/initializr/docs/current/reference/html/[Spring Initializr] by using an IDE integration in (https://joshlong.com/jl/blogPost/tech_tip_geting_started_with_spring_boot.html[Eclipse] or https://www.jetbrains.com/help/idea/spring-boot.html#d1489567e2[IntelliJ], https://github.com/AlexFalappa/nb-springboot/wiki/Quick-Tour[NetBeans]) or through https://start.spring.io.
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								Alternatively, you can manually add the starter, as the following example shows:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[tabs]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Maven::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								.pom.xml
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 15:46:32 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[source,xml,subs="verbatim,attributes"]
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<dependencies>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<!-- ... other dependency elements ... -->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<dependency>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<groupId>org.springframework.boot</groupId>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<artifactId>spring-boot-starter-security</artifactId>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									</dependency>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								</dependencies>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Gradle::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								.build.gradle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[source,groovy]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[subs="verbatim,attributes"]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								dependencies {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									implementation "org.springframework.boot:spring-boot-starter-security"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								Since Spring Boot provides a Maven BOM to manage dependency versions, you do not need to specify a version.
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								If you wish to override the Spring Security version, you can do so with a build property as shown below:
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[tabs]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Maven::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								.pom.xml
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 15:46:32 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[source,xml,subs="verbatim,attributes"]
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<properties>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<!-- ... -->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<spring-security.version>{spring-security-version}</spring-security.version>
							 
						 
					
						
							
								
									
										
										
										
											2022-02-02 10:30:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								</properties>
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Gradle::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								.build.gradle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[source,groovy]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[subs="verbatim,attributes"]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								ext['spring-security.version']='{spring-security-version}'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 16:01:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Since Spring Security makes breaking changes only in major releases, you can safely use a newer version of Spring Security with Spring Boot.
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								However, at times, you may need to update the version of Spring Framework as well.
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								You can do so by adding a build property like so:
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[tabs]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Maven::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								.pom.xml
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 15:46:32 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[source,xml,subs="verbatim,attributes"]
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<properties>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<!-- ... -->
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 15:46:32 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									<spring.version>{spring-core-version}</spring.version>
							 
						 
					
						
							
								
									
										
										
										
											2022-02-02 10:30:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								</properties>
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Gradle::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								.build.gradle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[source,groovy]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[subs="verbatim,attributes"]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								ext['spring.version']='{spring-core-version}'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-21 16:55:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								If you use additional features (such as LDAP, OAuth 2, and others), you need to also include the appropriate xref:modules.adoc#modules[Project Modules and Dependencies].
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-24 14:06:23 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[[getting-maven-no-boot]]
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								=== Standalone Usage (Without Spring Boot)
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								When you use Spring Security without Spring Boot, the preferred way is to use Spring Security's BOM to ensure that a consistent version of Spring Security is used throughout the entire project.
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[tabs]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Maven::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								.pom.xml
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 15:46:32 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[source,xml,ubs="verbatim,attributes"]
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<dependencyManagement>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<dependencies>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<!-- ... other dependency elements ... -->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<dependency>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<groupId>org.springframework.security</groupId>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<artifactId>spring-security-bom</artifactId>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<version>{spring-security-version}</version>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<type>pom</type>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<scope>import</scope>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</dependency>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									</dependencies>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								</dependencyManagement>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Gradle::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								.build.gradle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[source,groovy]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[subs="verbatim,attributes"]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								plugins {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									id "io.spring.dependency-management" version "1.0.6.RELEASE"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								dependencyManagement {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									imports {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										mavenBom 'org.springframework.security:spring-security-bom:{spring-security-version}'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[TIP]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Spring provides a https://github.com/spring-gradle-plugins/dependency-management-plugin[`Dependency Management Plugin`] for Gradle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 16:01:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								A minimal Spring Security Maven set of dependencies typically looks like the following example:
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[tabs]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Maven::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								.pom.xml
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 15:46:32 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[source,xml,subs="verbatim,attributes"]
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<dependencies>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<!-- ... other dependency elements ... -->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<dependency>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<groupId>org.springframework.security</groupId>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<artifactId>spring-security-web</artifactId>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									</dependency>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<dependency>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<groupId>org.springframework.security</groupId>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<artifactId>spring-security-config</artifactId>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									</dependency>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								</dependencies>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Gradle::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								.build.gradle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[source,groovy]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[subs="verbatim,attributes"]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								dependencies {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									implementation "org.springframework.security:spring-security-web"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									implementation "org.springframework.security:spring-security-config"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-21 16:55:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								If you use additional features (such as LDAP, OAuth 2, and others), you need to also include the appropriate xref:modules.adoc#modules[Project Modules and Dependencies].
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 15:46:32 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Spring Security builds against Spring Framework {spring-core-version} but should generally work with any newer version of Spring Framework 5.x.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Many users are likely to run afoul of the fact that Spring Security's transitive dependencies resolve Spring Framework {spring-core-version}, which can cause strange classpath problems.
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The easiest way to resolve this is to use the `spring-framework-bom` within the `<dependencyManagement>` section of your `pom.xml` or your `dependencyManagement` section of your `build.gradle`.
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[tabs]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Maven::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								.pom.xml
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 15:46:32 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[source,xml,subs="verbatim,attributes"]
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<dependencyManagement>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<dependencies>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<!-- ... other dependency elements ... -->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<dependency>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<groupId>org.springframework</groupId>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<artifactId>spring-framework-bom</artifactId>
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 15:46:32 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											<version>{spring-core-version}</version>
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											<type>pom</type>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											<scope>import</scope>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										</dependency>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									</dependencies>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								</dependencyManagement>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Gradle::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								.build.gradle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[source,groovy]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[subs="verbatim,attributes"]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								plugins {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									id "io.spring.dependency-management" version "1.0.6.RELEASE"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								dependencyManagement {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									imports {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										mavenBom 'org.springframework:spring-framework-bom:{spring-core-version}'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[TIP]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Spring provides a https://github.com/spring-gradle-plugins/dependency-management-plugin[`Dependency Management Plugin`] for Gradle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-13 15:46:32 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								The preceding example ensures that all the transitive dependencies of Spring Security use the Spring {spring-core-version} modules.
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-04 14:12:59 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[NOTE]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								====
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								This approach uses Maven's "`bill of materials`" (BOM) concept and is only available in Maven 2.0.9+.
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 07:43:35 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								For additional details about how dependencies are resolved, see https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html[Maven's Introduction to the Dependency Mechanism documentation].
							 
						 
					
						
							
								
									
										
										
										
											2021-06-04 14:12:59 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								====
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-10 15:45:02 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[[maven-repositories]]
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								=== Maven Repositories
							 
						 
					
						
							
								
									
										
										
										
											2024-12-10 15:49:54 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								All https://github.com/spring-projects/spring-security/wiki/Release-Schedule-Guidelines[GA releases] are deployed to Maven Central, so you need not declare additional Maven repositories in your build configuration.
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								For Gradle using the `mavenCentral()` repository is sufficient for GA releases.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								.build.gradle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[source,groovy]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								repositories {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									mavenCentral()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 16:01:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								If you use a SNAPSHOT version, you need to ensure that you have the Spring Snapshot repository defined:
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[tabs]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Maven::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								.pom.xml
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[source,xml]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<repositories>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<!-- ... possibly other repository elements ... -->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<repository>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<id>spring-snapshot</id>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<name>Spring Snapshot Repository</name>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<url>https://repo.spring.io/snapshot</url>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									</repository>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								</repositories>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Gradle::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								.build.gradle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[source,groovy]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								repositories {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									maven { url 'https://repo.spring.io/snapshot' }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								If you use a milestone or release candidate version, you need to ensure that you have the Spring Milestone repository defined, as the following example shows:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								[tabs]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								======
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Maven::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								.pom.xml
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[source,xml]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<repositories>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<!-- ... possibly other repository elements ... -->
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									<repository>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<id>spring-milestone</id>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<name>Spring Milestone Repository</name>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										<url>https://repo.spring.io/milestone</url>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									</repository>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								</repositories>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Gradle::
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								+
							 
						 
					
						
							
								
									
										
										
										
											2019-09-30 06:58:37 -06:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								.build.gradle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[source,groovy]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								repositories {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									maven { url 'https://repo.spring.io/milestone' }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								----
							 
						 
					
						
							
								
									
										
										
										
											2024-12-09 00:43:36 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								======