Resolution of the jar version conflict problem in Maven

Source: Internet
Author: User

For example, the Struts-core,hibernate-core is introduced in the parent project and the jar package is found to be in conflict. Javassist There is a conflict on the version.

Method One:

<Dependency>          <groupId>Org.apache.struts</groupId>          <Artifactid>Struts2-core</Artifactid>          <version>2.3.24</version>          <!--Lock this javassist . -          <Exclusions>              <exclusion>                  <Artifactid>Javassist</Artifactid>                  <groupId>Javassist</groupId>              </exclusion>          </Exclusions>      </Dependency>

After OK, the dependency in the Pom.xml file will have an extra exclusions tag to lock the package you want to lock.

Method Two: Set the jar package to be locked directly in the dependencymanagement tag in the Pom.xml file.

<!--version Lock Management -  <dependencymanagement>      <Dependencies>          <Dependency>              <groupId>Org.springframework</groupId>              <Artifactid>Spring-beans</Artifactid>              <version>4.2.4.RELEASE</version>          </Dependency>          <Dependency>              <groupId>Org.springframework</groupId>              <Artifactid>Spring-context</Artifactid>              <version>4.2.4.RELEASE</version>          </Dependency>      </Dependencies>  </dependencymanagement>

To invoke those jar packages that are locked, it is possible to invoke the dependencies tag outside of the dependencymanagement.

<!--use a locked version (no version number is specified) -      <Dependency>          <groupId>Org.springframework</groupId>          <Artifactid>Spring-beans</Artifactid>      </Dependency>      <Dependency>          <groupId>Org.springframework</groupId>          <Artifactid>Spring-context</Artifactid>      </Dependency>

Method Three: Specify the version number in the Properties tab in the Pom.xml file.

  <!--version of Lock -  <Properties>      <spring.version>4.2.4.RELEASE</spring.version>      <struts.version>2.3.24</struts.version>      <hibernate.version>5.0.7.Final</hibernate.version>      <mysql.version>5.1.6</mysql.version>      <log4j.version>1.2.12</log4j.version>  </Properties>

When the jar package is introduced, it is declared as an annotated version.

      <!--use a locked version -      <Dependency>          <groupId>Org.springframework</groupId>          <Artifactid>Spring-web</Artifactid>          <version>${spring.version}</version>      </Dependency>

Resolution of the jar version conflict problem in Maven

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.