I'm going through one confusion. where I'm using 2 external jars (one.jar, two.jar) in my maven java project.
one.jar
calls/use two.jar
as a dependency. If two.jar
version was lets say 1.1.1
while building up one.jar
, so will it work if I import both jars in my code to use and rename two.jar to 1.1.2 version ? Would one.jar would be able to find two.jar with different name ?
Want to know, will name change of jar could be found to by its caller ?
CodePudding user response:
At runtime it doesn't work like that. It's not like that one jar will try to find another jar. Or specific version of the jar. It's class which try to find and load another class to resolve the dependencies.
If updated version of jar has backward compatibility, you won't face any issue, otherwise you might face some runtime issues. For that you might need to read the release notes of the jar and try to find how it might impact the jar which is using it.
CodePudding user response:
If you are using a war file and have not used provided scope in dependency of jar1 and jar1 has also not used provided scope in dependency to jar2, it will be packed in .war file. So name change of jar2 will affect only when war is rebuild
For standalone projects
If external jars are installed in repo and used from repo, then impact of changing jar name will start when you recompile the main project after name change. It may not compile depending on scope used in defining dependency from main project to jar1 and also on jar1 to jar2
examples
If jar1 is using jar2 as part of its src folder then name change will not affect as it jar2 will be included in jar1
If jar1 is using jar2 from maven repo then name change will affect depending on scope