Maven Jar package conflict

Project scene:

Record one by one problem today


Problem Description:

Because the WeChat applet calls the WeChat api interface, and the returned data is encrypted, it needs to solve the puzzle in the background, but it introduces

 <dependency>
            <groupId>org.codehaus.xfire</groupId>
            <artifactId>xfire-all</artifactId>
            <version>1.2.4</version>
        </dependency>

The previous code has the following problem
Insert picture description here


Cause Analysis:

Dependency transfer principle

1. The shortest path first principle

If two Jar packages A and B are introduced, both of them transitively depend on the Jar package Z:

A -> X -> Y -> Z(2.5)

B -> X -> Z(2.0)
In fact, the final effective version is Z(2.0). Because his path is shorter.

2. Declare the principle of priority first

If the path length is the same, the one declared first is preferred.

A -> Z(3.0)

B -> Z(2.5)


solution:

Speaking of this, I believe everyone knows how to do it

 <dependency>
            <groupId>org.codehaus.xfire</groupId>
            <artifactId>xfire-all</artifactId>
            <version>1.2.4</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring</artifactId>

                </exclusion>
            </exclusions>
        </dependency>

Guess you like

Origin blog.csdn.net/qq_44688861/article/details/115290690