Skip to content

Commit 6f73f26

Browse files
committed
Add warning about overriding Spring Boot managed dependency versions.
Additionally, edit the sub-chapter (section) on dependency version overriding.
1 parent 1a2cd01 commit 6f73f26

File tree

1 file changed

+32
-38
lines changed
  • spring-geode-project/spring-geode-docs/src/docs/asciidoc

1 file changed

+32
-38
lines changed

spring-geode-project/spring-geode-docs/src/docs/asciidoc/index.adoc

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -575,25 +575,33 @@ All of this is made simple by going to https://start.spring.io[start.spring.io]
575575
=== Overriding Dependency Versions
576576

577577
While Spring Boot for {apache-geode-name} requires baseline versions of the <<sbdg-dependency-versions,primary dependencies>>
578-
outlined above, it is possible, using Spring Boot's dependency management functionality, to override the versions of
579-
3rd-party dependencies (Java libraries) managed by Spring Boot itself.
578+
listed above, it is possible, using Spring Boot's dependency management capabilities, to override the versions of
579+
3rd-party Java libraries and dependencies managed by Spring Boot itself.
580580

581581
When your Spring Boot application Maven POM inherits from the `org.springframework.boot:spring-boot-starter-parent`,
582-
or alternatively, applies the Spring Dependency Management Gradle Plugin (`io.spring.dependency-management`)
583-
in addition to the Spring Boot Gradle Plugin (`org.springframework.boot`) in your Spring Boot application Gradle
584-
build file, then you automatically enable the dependency management capabilities provided by Spring Boot for all
585-
3rd-party dependencies and Java libraries curated and managed by Spring Boot.
582+
or alternatively, applies the Spring Dependency Management Gradle Plugin (`io.spring.dependency-management`) along with
583+
the Spring Boot Gradle Plugin (`org.springframework.boot`) in your Spring Boot application Gradle build file, then you
584+
automatically enable the dependency management capabilities provided by Spring Boot for all 3rd-party Java libraries
585+
and dependencies curated and managed by Spring Boot.
586586

587-
Spring Boot's dependency management harmonizes all 3rd-party Java libraries and dependencies that you, the user,
588-
are likely to use in your Spring Boot applications. All of these curated dependencies have been tested and proven to
589-
work with the version of Spring Boot along with all other Spring dependencies (e.g. Spring Data, Spring Security)
590-
that you may also be using in your Spring Boot applications.
587+
Spring Boot's dependency management harmonizes all 3rd-party Java libraries and dependencies that you are likely to use
588+
in your Spring Boot applications. All these dependencies have been tested and proven to work with the version of Spring
589+
Boot and other Spring dependencies (e.g. Spring Data, Spring Security) you may be using in your Spring Boot applications.
591590

592591
Still, there may be times when you want, or even need to override the version of some 3rd-party Java libraries used by
593592
your Spring Boot applications, that are specifically managed by Spring Boot. In cases where you know that using a
594593
different version of a managed dependency is safe to do so, then you have a few options for how to override
595594
the dependency version:
596595

596+
WARNING: Use caution when overriding dependencies since they may not be compatible with other dependencies managed by
597+
Spring Boot for which you may have declared on your application classpath, for example, by adding a starter. It is
598+
common for multiple Java libraries to share the same transitive dependencies but use different versions of the Java
599+
library (e.g. logging). This will often lead to Exceptions thrown at runtime due to API differences. Keep in mind that
600+
Java resolves classes on the classpath from the first class definition that is found in the order that JARs or paths
601+
have been defined on the classpath. Finally, Spring does not support dependency versions that have been overridden
602+
and do not match the versions declared and managed by Spring Boot.
603+
See {spring-boot-docs-html}/#appendix.dependency-versions.coordinates[documentation].
604+
597605
* <<sbdg-dependency-version-overrides-property>>
598606
* <<sbdg-dependency-version-overrides-dependencymanagement>>
599607

@@ -623,28 +631,15 @@ ext['log4j2.version'] = '2.17.2'
623631
----
624632

625633
NOTE: The Log4j version number used in the Maven and Gradle examples shown above is arbitrary. You must set
626-
the `log4j2.version` property to a valid Log4j version that would be resolvable by Maven or Gradle,
627-
given the fully qualified artifact: `org.apache.logging.log4j:log4j:2.17.2`.
634+
the `log4j2.version` property to a valid Log4j version that would be resolvable by Maven or Gradle when given
635+
the fully qualified artifact: `org.apache.logging.log4j:log4j:2.17.2`.
628636

629637
The version property name must precisely match the version property declared in the `spring-boot-dependencies`
630638
Maven POM.
631639

632-
ifeval::["{version-snapshot}" == "true"]
633-
See the https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-dependencies/{spring-boot-version}/spring-boot-dependencies-{spring-boot-version}.pom[spring-boot-dependencies POM]
634-
containing version properties for all the dependencies managed by Spring Boot.
635-
endif::[]
636-
637-
ifeval::["{version-milestone}" == "true"]
638-
See the https://repo.spring.io/milestone/org/springframework/boot/spring-boot-dependencies/{spring-boot-version}/spring-boot-dependencies-{spring-boot-version}.pom[spring-boot-dependencies POM]
639-
containing version properties for all the dependencies managed by Spring Boot.
640-
endif::[]
641-
642-
ifeval::["{version-release}" == "true"]
643-
See the https://repo.spring.io/artifactory/milestone/org/springframework/boot/spring-boot-dependencies/{spring-boot-version}/spring-boot-dependencies-{spring-boot-version}.pom[spring-boot-dependencies POM]
644-
containing version properties for all the dependencies managed by Spring Boot.
645-
endif::[]
640+
See Spring Boot's documentation on {spring-boot-docs-html}/#appendix.dependency-versions.properties[version properties].
646641

647-
More details can be found in the Spring Boot Maven Plugin
642+
Additional details can be found in the Spring Boot Maven Plugin
648643
https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle/#using.parent-pom[documentation]
649644
as well as the Spring Boot Gradle Plugin
650645
https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#managing-dependencies[documentation].
@@ -653,17 +648,16 @@ https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsing
653648
==== Override with Dependency Management
654649

655650
This option is not specific to Spring in general, or Spring Boot in particular, but applies to Maven and Gradle,
656-
which both intrinsically have dependency management features and capabilities.
651+
which both have intrinsic dependency management features and capabilities.
657652

658-
This approach is useful not only to control the versions of the dependencies managed by Spring Boot directly, but also
659-
to control the versions of dependencies that may be transitively pulled in by the dependencies that are managed by
660-
Spring Boot. Additionally, this approach is also more universally transferrable since it is handled by Maven or Gradle
661-
itself.
653+
This approach is useful to not only control the versions of the dependencies managed by Spring Boot directly, but also
654+
control the versions of dependencies that may be transitively pulled in by the dependencies that are managed by
655+
Spring Boot. Additionally, this approach is more universal since it is handled by Maven or Gradle itself.
662656

663657
For example, when you declare the `org.springframework.boot:spring-boot-starter-test` dependency in your Spring Boot
664658
application Maven POM or Gradle build file for testing purposes, you will see a dependency tree similar to:
665659

666-
.$gradlew dependencies OR $mvn dependency:tree
660+
.`$gradlew dependencies` OR `$mvn dependency:tree`
667661
[source,xml]
668662
----
669663
...
@@ -691,12 +685,12 @@ application Maven POM or Gradle build file for testing purposes, you will see a
691685
----
692686

693687
If you wanted to override and control the version of the `opentest4j` transitive dependency, for whatever reason,
694-
perhapsbecause you are using the `opentest4j` API directly in your application tests, then you could add dependency
688+
perhaps because you are using the `opentest4j` API directly in your application tests, then you could add dependency
695689
management in either Maven or Gradle to control the `opentest4j` dependency version.
696690

697-
Note that the `opentest4j` dependency is pulled in by JUnit and is not a dependency that Spring Boot specifically
698-
manages. Of course, Maven or Gradle's dependency management capabilities can be used to override dependencies that are
699-
managed by Spring Boot, too.
691+
NOTE: The `opentest4j` dependency is pulled in by JUnit and is not a dependency that Spring Boot specifically manages.
692+
Of course, Maven or Gradle's dependency management capabilities can be used to override dependencies that are managed
693+
by Spring Boot as well.
700694

701695
Using the `opentest4j` dependency as an example, you can override the dependency version by doing the following:
702696

@@ -737,7 +731,7 @@ dependencyManagement {
737731

738732
After applying Maven or Gradle dependency management configuration, you will then see:
739733

740-
.$gradlew dependencies OR $mvn dependency:tree
734+
.`$gradlew dependencies` OR `$mvn dependency:tree`
741735
[source,xml]
742736
----
743737
...

0 commit comments

Comments
 (0)