版本沖突的解決方案
[1]調節原則
[1]路徑最短者優先原則
[2]路徑相同時,先聲明者優先原則
[2]排除原則:用於排除某項依賴的依賴jar包
1 <dependency>
2 <groupId>javax.servlet</groupId>
3 <artifactId>servlet-api</artifactId>
4 <version>2.5</version>
5 <exclusions>
6 <exclusion>
7 <groupId></groupId>
8 <artifactId></artifactId>
9 <!--這里不需要指定版本號,由於是排除特定依賴的某個依賴jar包,所以版本固定,不需指定 -->
10 </exclusion>
11 </exclusions>
12 <scope>provided</scope>
13 </dependency>
[3]版本鎖定原則:一般用在繼承項目的父項目中
1 <dependencyManagement>
2 <dependencies>
3 <dependency>
4 <!--jar包坐標 -->
5 <groupId></groupId>
6 <artifactId></artifactId>
7 <version></version>
8 </dependency>
9 </dependencies>
10 </dependencyManagement>
1、版本鎖定之后,后面再使用到這個的 依賴的時候,就不要寫版本號了!
2、而且如果有多個相同的需要鎖定的jar包的版本號一致的話,我們可以單獨提取到properties標簽中,
3、在properties標簽中,子標簽自己定義,標簽的值就是版本號,下面只需要在依賴的地方用${標簽名}引用就可以了!