Maven install using different version of hava
This makes our project more mistake proof, but requires us to be more explicit in our pom.xml files. We must either specify the version to use, or set up dependencyManagement in the parent pom.xml. Let's add the maven-enforcer-plugin with that rule to our parent pom: Īs a consequence, we must now explicitly declare the artifact in our project-collision module if we want to use it ourselves. One of them bans the use of classes and methods from transitive dependencies.Įxplicit dependency declaration removes the possibility of version collision of artifacts. The maven-enforcer-plugin provides many built-in rules that simplify the management of a multi-module project. Make sure a recent version of Maven 3, ideally 3.8.3 or newer, is provided if you decide to go this route. On macOS, the Homebrew package manager offers Maven packages. Consult your distribution’s documentation for details. This variant is useful when final image size being as small as possible is your primary concern. Alpine Linux is much smaller than most distribution base images (5MB), and thus leads to much slimmer images in general.
MAVEN INSTALL USING DIFFERENT VERSION OF HAVA UPGRADE
\- :guava:jar:29.0-jre:compileĪs a result, the compilation phase ends without an error and we can use the classes and methods from version 29.0-jre. Many Linux distributions provide packages for Maven for an easier install and upgrade experience. This image is based on the popular Alpine Linux project, available in the alpine official image. \- com.baeldung:project-b:jar:0.0.1-SNAPSHOT:compile
com.baeldung:project-collision:jar:0.0.1-SNAPSHOT maven-dependency-plugin:2.8:tree (default-cli) project-collision. Next, we need to move to the Maven section and click on the Maven Installations button. Here we have to either give Name and JAVAHOME path or this can be taken care of by checking Install automatically checkbox. For Java set up, click on the JDK Installations button. Now, when we run the dependency:tree command, we can see that it's not there anymore: % mvn dependency:tree -Dverbose Then click on Global Tool Configurations.Here we have to do the configurations for Java and Maven. Therefore, we can exclude it in the project-collision pom: In our example, we don't want to have the library transitively added from the project-a artifact. One way to resolve a version collision is by removing a conflicting transitive dependency from specific artifacts.