The versions of the starter atrifacts are managed in the starter parent. For example, if you have this in your POM:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent>
Then any boot starter dependency you reference will have version 2.0.2.RELEASE, unless you override the default and provide your own version for some reason.
Answer from Michael Peacock on Stack OverflowThe versions of the starter atrifacts are managed in the starter parent. For example, if you have this in your POM:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent>
Then any boot starter dependency you reference will have version 2.0.2.RELEASE, unless you override the default and provide your own version for some reason.
This is related not only to starters, if you have many modules in your project they have different dependencies. As regular practice, there is a parent pom.xml with general settings.
If you see a dependency in child maven module like below:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
There is a configured dependency in parent pom like:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
Usually, it's more flexible to configure versions with properties:
<properties>
<commons-lang3.version>3.5</commons-lang3.version>
</properties>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
MongoDb version is defined in spring-boot-dependencies using Dependency Management mechanism.
<properties>
<mongodb.version>3.8.0-beta2</mongodb.version>
<properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>${mongodb.version}</version>
</dependency>
<dependencies>
<dependencyManagement>
Dependency management is a mechanism for centralizing dependency information. When you have a set of projects that inherits a common parent it's possible to put all information about the dependency in the common POM and have simpler references to the artifacts in the child POMs.
As far as I can see the spring boot starter parent depends only on commons-lang3 and not on commons-lang (which is reasonable because commons-lang3 is a newer replacement for commons-lang).
It doesn't matter that your .m2 directory contains commons-lang (probably due to some other project depending on it): as long as your project hasn't declared a (direct or indirect) dependency on commons-lang, none of its classes will be on your classpath.
Call mvn dependency:tree on your "other" project. Here you can see through which path you drew commons-lang. Joachim Sauer is probably right and it is a transitive dependency that you started to use like a direct one.
Best fix would be to start to use commons-lang3 for your project (again, Joachim Sauer is right here), second best fix would be to declare commons-lang as a direct dependency in your pom.xml.