Skip to content

Commit

Permalink
Incorporate PR review feedback for "getting-spring-security" document…
Browse files Browse the repository at this point in the history
…ation (spring-projects#16234)

- Fixed minor formatting issues and addressed reviewer suggestions.
- Issue spring-projectsgh-16228.
  • Loading branch information
harpreets789 committed Dec 10, 2024
1 parent 6fe76f5 commit 18a0e53
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions docs/modules/ROOT/pages/getting-spring-security.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[[getting]]
[[getting-gradle]]
= Getting Spring Security

This section describes how to get the Spring Security binaries.
Expand All @@ -15,13 +16,13 @@ Typically, these are done to provide improved security to match modern security


[[maven]]
== Usage with Maven and Gradle
== Usage

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.

[[getting-maven-boot]]
[[getting-gradle-boot]]
=== Spring Boot with Maven and Gradle
=== Spring Boot

Spring Boot provides a `spring-boot-starter-security` starter that aggregates Spring Security-related dependencies.
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.
Expand Down Expand Up @@ -56,7 +57,7 @@ dependencies {
======

Since Spring Boot provides a Maven BOM to manage dependency versions, you do not need to specify a version.
If you wish to override the Spring Security version, you can do so by providing a Maven property or declaring it as a Gradle property, as shown below:
If you wish to override the Spring Security version, you can do so with a build property as shown below:

[tabs]
======
Expand All @@ -83,7 +84,7 @@ ext['spring-security.version']='{spring-security-version}'

Since Spring Security makes breaking changes only in major releases, you can safely use a newer version of Spring Security with Spring Boot.
However, at times, you may need to update the version of Spring Framework as well.
You can do so by adding a Maven or Gradle property:
You can do so by adding a build property like so:

[tabs]
======
Expand Down Expand Up @@ -113,7 +114,7 @@ If you use additional features (such as LDAP, OAuth 2, and others), you need to
[[getting-maven-no-boot]]
=== Standalone Usage (Without Spring Boot)

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. For Gradle, you can do so by using the https://github.com/spring-gradle-plugins/dependency-management-plugin[Dependency Management Plugin]:
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.

[tabs]
======
Expand Down Expand Up @@ -154,6 +155,8 @@ dependencyManagement {
----
======

[TIP]
Spring provides a https://github.com/spring-gradle-plugins/dependency-management-plugin[`Dependency Management Plugin`] for Gradle

A minimal Spring Security Maven set of dependencies typically looks like the following example:

Expand Down Expand Up @@ -194,7 +197,7 @@ If you use additional features (such as LDAP, OAuth 2, and others), you need to

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.
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`. For Gradle, you can do so by using the https://github.com/spring-gradle-plugins/dependency-management-plugin[Dependency Management Plugin]:
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`.

[tabs]
======
Expand Down Expand Up @@ -235,6 +238,9 @@ dependencyManagement {
----
======

[TIP]
Spring provides a https://github.com/spring-gradle-plugins/dependency-management-plugin[`Dependency Management Plugin`] for Gradle

The preceding example ensures that all the transitive dependencies of Spring Security use the Spring {spring-core-version} modules.

[NOTE]
Expand All @@ -243,9 +249,11 @@ This approach uses Maven's "`bill of materials`" (BOM) concept and is only avail
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].
====

[[maven-gradle-gearepositories]]
=== Maven and Gradle Repositories
All GA releases (that is, versions ending in .RELEASE) are deployed to Maven Central, so you need not declare additional Maven repositories in your `pom.xml` or, for Gradle, using the `mavenCentral()` repository is sufficient for GA releases.
[[maven-gearepositories]]
=== Maven Repositories
All GA releases (that is, versions ending in .RELEASE) are deployed to Maven Central, so you need not declare additional Maven repositories in your `pom.xml`.

For Gradle using the `mavenCentral()` repository is sufficient for GA releases.

.build.gradle
[source,groovy]
Expand Down

0 comments on commit 18a0e53

Please sign in to comment.