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