How to pass dependencies using different versions of Maven of the same name at the same time

my Maven dependency tree is as follows

Self
+- A
|  \- C 2.x
\- B
   \- C 3.x

the project relies on two libraries of AMagi B, which uses different versions of the C library, and the reference to C is necessary, and the two versions are not compatible with each other

how do I resolve this dependency conflict?

Mar.18,2021

you can simply screen A to avoid dependence on C, using the following method

<dependency>
            <groupId>A</groupId>
            <artifactId>A</artifactId>
            <version>1.0</version>
            <exclusions>
                <exclusion>
                    <groupId>C</groupId>
                    <artifactId>C</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

but if A's dependence on C is necessary and incompatible, there is no good way but to repackage or upgrade with source code.
maybe modules or microservices are a direction, but they are too heavy.


Brother, have you found any reasonable solutions? I happen to encounter this problem at the same time. I'd like to ask

.
Menu