父pom定义了属性“child.version = 2.0”
parent pom.xml
<project>
<groupId>com.xxx</groupId>
<!-- 父pom名 -->
<artifactId>parent-xxx</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
<!-- 子pom名 -->
<module>child1</module>
<module>child2</module>
</modules>
<properties>
<!-- version属性 -->
<child.version>2.0</child.version>
</properties>
</project>
子pom child1 依赖了child2,child2的版本号是父pom定义的properties属性。
child1 pom.xml
<project>
<parent>
<groupId>com.xxx</groupId>
<artifactId>child</artifactId>
<version>1.0</version>
</parent>
<!-- 子pom名 -->
<artifactId>child1</artifactId>
<dependencies>
<dependency>
<groupId>com.xxx</groupId>
<artifactId>child2</artifactId>
<version>${child.version}</version>
</dependency>
</dependencies>
</project>
child2 pom.xml
<project>
<parent>
<groupId>com.xxx</groupId>
<artifactId>child</artifactId>
<version>1.0</version>
</parent>
<artifactId>child2</artifactId>
<version>${child.version}</version>
</project>
child1依赖了child2,child2的版本定义在parent properties中。
child1 和child2 有共同的parent,所以child能解析child2的版本。
而此时,第三方依赖了child1后,由依赖传递 也依赖了child2,但第三方无法解析child2的版本${child.version}。
问题:如何可以继续使用动态配置version保证一致性,同时还能让第三方能解析配置?
增加规则文件。rule.xml进行动态匹配。具体思路可以参考灰度发布。
比如我同时使用1.0和2.0版本的服务。在对方调用的时候收集指定版本。动态匹配到对应版本。
给你个例子可以参考。
github: https://github.com/Nepxion/Di...
搜索