Issue
Example code:
https://github.com/yszzu1/mvn-version-test
Question:
1. why the admin-module always using ojdbc8 19.3.0.0 ?
# mvn dependency:tree
[INFO] --- maven-dependency-plugin:3.1.2:tree (default-cli) @ admin-module ---
[INFO] org.example:admin-module:jar:3.12.0
[INFO] +- org.example:db-module:jar:3.12.0:compile
[INFO] | \- com.oracle.database.jdbc:ojdbc8:jar:19.3.0.0:compile
as we can see that the db-module is using 19.9.0.0
2. even after upgrade the db-module pom.xml
with
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>21.1.0.0</version>
</dependency>
, the admin-module mvn dependency:tree
is still showing 19.3.0.0
mvn & windows & JVM version:
# mvn --version
Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
Maven home: C:\Users\shuayan\Documents\open\apache-maven-3.8.5
Java version: 1.8.0_321, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_321\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"
BTW: I have read these two wiki
https://www.mojohaus.org/versions-maven-plugin/faq.html
https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN401
Solution
That is how dependency management works in maven.
- you have defined direct ojdbc8 dependency for db-module and it does work as expected
- for admin-module the situation is "bit different":
- it depends directly on db-module, and ojdbc8 is now a transitive dependency
- it inherits ojdbc8 version from spring-boot-starter-parent (actually from spring-boot-dependencies)
if you really want to use spring-boot-starter-parent
as a parent you need to configure your project in the following way:
/pom.xml:
<properties>
...
<ojdbc.version>21.1.0.0</ojdbc.version>
<oracle-database.version>21.1.0.0</oracle-database.version>
...
</properties>
/db-module/pom.xml:
<dependencies>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<!-- omit version information -->
</dependency>
</dependencies>
Answered By - Andrey B. Panfilov
Answer Checked By - Marie Seifert (JavaFixing Admin)