1. 程式人生 > >maven 解決依賴衝突 omiit for conflict

maven 解決依賴衝突 omiit for conflict

maven依賴衝突,原因:

衝突寫法如下:

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.3.3</version>
        </dependency>

衝突:


這裡是因為在httpclient中已經包含了httpcore,而下面又單獨引入了httpcore。

解決方法:

        方法一:   直接刪除第二個單獨引入的httpcore。看情況

        方法二: 將httpclient中加入<exclusions>標籤

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.5</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpcore</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.3.3</version>
        </dependency>