You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can get hold of Spring Security in several ways.
5
-
You can download a packaged distribution from the main http://spring.io/spring-security[Spring Security] page, download individual jars from the Maven Central repository (or a Spring Maven repository for snapshot and milestone releases) or, alternatively, you can build the project from source yourself.
6
-
4
+
This section discusses all you need to know about getting the Spring Security binaries.
5
+
Please refer to <<community-source>> for how to obtain the source code.
7
6
8
7
== Release Numbering
9
8
@@ -18,6 +17,81 @@ Typically these are done to provide improved security to match modern security p
18
17
[[maven]]
19
18
== Usage with Maven
20
19
20
+
Like most open source projects, Spring Security deploys its dependencies as Maven artifacts.
21
+
The following sections provide details on how to consume Spring Security when using Maven.
22
+
23
+
=== Spring Boot with Maven
24
+
25
+
Spring Boot provides a spring-boot-starter-security starter which aggregates Spring Security related dependencies together.
26
+
The simplest and preferred method to leverage the starter is to use https://docs.spring.io/initializr/docs/current/reference/htmlsingle/[Spring Initializr] using an IDE integration (http://joshlong.com/jl/blogPost/tech_tip_geting_started_with_spring_boot.html[Eclipse], 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.
Since Spring Security only makes breaking changes in major releases, it is safe to use a newer version of Spring Security with Spring Boot.
57
+
However, at times it may be necessary to update the version of Spring Framework as well.
58
+
This can easily be done by adding a Maven property as well:
59
+
60
+
.pom.xml
61
+
[source,xml]
62
+
[subs="verbatim,attributes"]
63
+
----
64
+
<properties>
65
+
<!-- ... -->
66
+
<spring.version>{spring-version}</spring.version>
67
+
</dependencies>
68
+
----
69
+
70
+
If you are using additional features like LDAP, OpenID, etc. you will need to also include the appropriate <<modules>>.
71
+
72
+
=== Maven Without Spring Boot
73
+
74
+
When using Spring Security without Spring Boot, the preferred way is to leverage Spring Security's BOM to ensure a consistent version of Spring Security is used throughout the entire project.
75
+
76
+
.pom.xml
77
+
[source,xml]
78
+
[subs="verbatim,attributes"]
79
+
----
80
+
<dependencyManagement>
81
+
<dependencies>
82
+
<!-- ... other dependency elements ... -->
83
+
<dependency>
84
+
<groupId>org.springframework.security</groupId>
85
+
<artifactId>spring-security-bom</artifactId>
86
+
<version>{spring-security-version}</version>
87
+
<type>pom</type>
88
+
<scope>import</scope>
89
+
</dependency>
90
+
</dependencies>
91
+
</dependencyManagement>
92
+
----
93
+
94
+
21
95
A minimal Spring Security Maven set of dependencies typically looks like the following:
22
96
23
97
.pom.xml
@@ -29,18 +103,43 @@ A minimal Spring Security Maven set of dependencies typically looks like the fol
29
103
<dependency>
30
104
<groupId>org.springframework.security</groupId>
31
105
<artifactId>spring-security-web</artifactId>
32
-
<version>{spring-security-version}</version>
33
106
</dependency>
34
107
<dependency>
35
108
<groupId>org.springframework.security</groupId>
36
109
<artifactId>spring-security-config</artifactId>
37
-
<version>{spring-security-version}</version>
38
110
</dependency>
39
111
</dependencies>
40
112
----
41
113
42
114
If you are using additional features like LDAP, OpenID, etc. you will need to also include the appropriate <<modules>>.
43
115
116
+
Spring Security builds against Spring Framework {spring-version}, but should generally work with any newer version of Spring Framework 5.x
117
+
The problem that many users will have is that Spring Security's transitive dependencies resolve Spring Framework {spring-version} which can cause strange classpath problems.
118
+
The easiest way to resolve this is to use the `spring-framework-bom` within your `<dependencyManagement>` section of your `pom.xml` as shown below:
119
+
120
+
.pom.xml
121
+
[source,xml]
122
+
[subs="verbatim,attributes"]
123
+
----
124
+
<dependencyManagement>
125
+
<dependencies>
126
+
<!-- ... other dependency elements ... -->
127
+
<dependency>
128
+
<groupId>org.springframework</groupId>
129
+
<artifactId>spring-framework-bom</artifactId>
130
+
<version>{spring-version}</version>
131
+
<type>pom</type>
132
+
<scope>import</scope>
133
+
</dependency>
134
+
</dependencies>
135
+
</dependencyManagement>
136
+
----
137
+
138
+
This will ensure that all the transitive dependencies of Spring Security use the Spring {spring-version} modules.
139
+
140
+
NOTE: This approach uses Maven's "bill of materials" (BOM) concept and is only available in Maven 2.0.9+.
141
+
For additional details about how dependencies are resolved refer to http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html[Maven's Introduction to the Dependency Mechanism documentation].
142
+
44
143
[[maven-repositories]]
45
144
=== Maven Repositories
46
145
All GA releases (i.e. versions ending in .RELEASE) are deployed to Maven Central, so no additional Maven repositories need to be declared in your pom.
@@ -55,7 +154,7 @@ If you are using a SNAPSHOT version, you will need to ensure you have the Spring
55
154
<repository>
56
155
<id>spring-snapshot</id>
57
156
<name>Spring Snapshot Repository</name>
58
-
<url>http://repo.spring.io/snapshot</url>
157
+
<url>https://repo.spring.io/snapshot</url>
59
158
</repository>
60
159
</repositories>
61
160
----
@@ -70,58 +169,114 @@ If you are using a milestone or release candidate version, you will need to ensu
70
169
<repository>
71
170
<id>spring-milestone</id>
72
171
<name>Spring Milestone Repository</name>
73
-
<url>http://repo.spring.io/milestone</url>
172
+
<url>https://repo.spring.io/milestone</url>
74
173
</repository>
75
174
</repositories>
76
175
----
77
176
78
-
[[maven-bom]]
79
-
=== Spring Framework BOM
80
177
81
-
Spring Security builds against Spring Framework {spring-version}, but should work with 5
82
-
The problem that many users will have is that Spring Security's transitive dependencies resolve Spring Framework {spring-version} which can cause strange classpath problems.
178
+
[[gradle]]
179
+
== Gradle
83
180
84
-
One (tedious) way to circumvent this issue would be to include all the Spring Framework modules in a http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Management[<dependencyManagement>] section of your pom.
85
-
An alternative approach is to include the `spring-framework-bom` within your `<dependencyManagement>` section of your `pom.xml` as shown below:
181
+
Like most open source projects, Spring Security deploys its dependencies as Maven artifacts which allows for for first class Gradle support.
182
+
The following sections provide details on how to consume Spring Security when using Gradle.
86
183
87
-
.pom.xml
88
-
[source,xml]
184
+
=== Spring Boot with Gradle
185
+
186
+
Spring Boot provides a spring-boot-starter-security starter which aggregates Spring Security related dependencies together.
187
+
The simplest and preferred method to leverage the starter is to use https://docs.spring.io/initializr/docs/current/reference/htmlsingle/[Spring Initializr] using an IDE integration (http://joshlong.com/jl/blogPost/tech_tip_geting_started_with_spring_boot.html[Eclipse], 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.
This will ensure that all the transitive dependencies of Spring Security use the Spring {spring-version} modules.
200
+
Since Spring Boot provides a Maven BOM to manage dependency versions, there is no need to specify a version.
201
+
If you wish to override the Spring Security version, you may do so by providing a Gradle property:
105
202
106
-
NOTE: This approach uses Maven's "bill of materials" (BOM) concept and is only available in Maven 2.0.9+.
107
-
For additional details about how dependencies are resolved refer to http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html[Maven's Introduction to the Dependency Mechanism documentation].
A minimal Spring Security Gradle set of dependencies typically looks like the following:
210
+
Since Spring Security only makes breaking changes in major releases, it is safe to use a newer version of Spring Security with Spring Boot.
211
+
However, at times it may be necessary to update the version of Spring Framework as well.
212
+
This can easily be done by adding a Gradle property as well:
213
+
214
+
.build.gradle
215
+
[source,groovy]
216
+
[subs="verbatim,attributes"]
217
+
----
218
+
ext['spring.version']='{spring-version}'
219
+
----
220
+
221
+
If you are using additional features like LDAP, OpenID, etc. you will need to also include the appropriate <<modules>>.
222
+
223
+
=== Gradle Without Spring Boot
224
+
225
+
When using Spring Security without Spring Boot, the preferred way is to leverage Spring Security's BOM to ensure a consistent version of Spring Security is used throughout the entire project.
226
+
This can be done by using the https://github.com/spring-gradle-plugins/dependency-management-plugin[Dependency Management Plugin].
227
+
228
+
.build.gradle
229
+
[source,groovy]
230
+
[subs="verbatim,attributes"]
231
+
----
232
+
plugins {
233
+
id "io.spring.dependency-management" version "1.0.6.RELEASE"
If you are using additional features like LDAP, OpenID, etc. you will need to also include the appropriate <<modules>>.
124
257
258
+
Spring Security builds against Spring Framework {spring-version}, but should generally work with any newer version of Spring Framework 5.x
259
+
The problem that many users will have is that Spring Security's transitive dependencies resolve Spring Framework {spring-version} which can cause strange classpath problems.
260
+
The easiest way to resolve this is to use the `spring-framework-bom` within your `<dependencyManagement>` section of your `pom.xml` as shown below:
261
+
This can be done by using the https://github.com/spring-gradle-plugins/dependency-management-plugin[Dependency Management Plugin].
262
+
263
+
.build.gradle
264
+
[source,groovy]
265
+
[subs="verbatim,attributes"]
266
+
----
267
+
plugins {
268
+
id "io.spring.dependency-management" version "1.0.6.RELEASE"
This will ensure that all the transitive dependencies of Spring Security use the Spring {spring-version} modules.
279
+
125
280
[[gradle-repositories]]
126
281
=== Gradle Repositories
127
282
All GA releases (i.e. versions ending in .RELEASE) are deployed to Maven Central, so using the mavenCentral() repository is sufficient for GA releases.
@@ -153,27 +308,3 @@ repositories {
153
308
maven { url 'https://repo.spring.io/milestone' }
154
309
}
155
310
----
156
-
157
-
[[gradle-resolutionStrategy]]
158
-
=== Using Spring 4.0.x and Gradle
159
-
160
-
By default Gradle will use the newest version when resolving transitive versions.
161
-
This means that often times no additional work is necessary when running Spring Security {spring-security-version} with Spring Framework {spring-version}.
162
-
However, at times there can be issues that come up so it is best to mitigate this using http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html[Gradle's ResolutionStrategy] as shown below:
0 commit comments