org.activiti.dependencies 7.1.0.M6 造成版本衝突問題的解決

【直擊問題】

1 <activiti-dependencies.version>7.1.0.M6</activiti-dependencies.version><!--默認依賴 org.springframework version:5.1.13 -->
2 <activiti-dependencies.version>7.1.0.M5</activiti-dependencies.version><!--默認依賴 org.springframework version:5.1.11-->
3 <activiti-dependencies.version>7.1.0.M4</activiti-dependencies.version><!--默認依賴 org.springframework version:5.1.8-->
4 <spring-cloud.version>Greenwich.SR1</spring-cloud.version><!--默認依賴 org.springframework version:5.1.11 -->

1. 我使用的 springboot 版本是 2.1.10.RELEASE,springcloud版本是 Greenwich.SR1 ,按照默認的情況下,如果結合 activiti 使用,需要使用版本 7.1.0.M5 則正合適。但是,經過嘗試,版本 7.1.0.M5 存在諸多問題,較直接的一個問題是,spring.activiti.database-schema-update=drop-create 該策略模式下,執行默認提供的多條創建表的sql語句無法創建正確的數據表結構,記憶深刻的有 act_re_deployment 表中,在建表語句中,少了 VISION 字段。啓動之初,先執行建表語句,啓動繼續進行,驗證時報錯,報找不到 VISION 字段的錯誤。

2. 在使用 spring-boot-starter-quartz 時,springboot自動配置裏面的 org.springframework.boot.autoconfigure.quartz 中 QuartzAutoConfiguration 2.1.10.RELEASE 依賴的 spring 版本是 org.springframework version:5.1.11

【最終方案】

<activiti-dependencies.version> 採用 7.1.0.M5
<spring-cloud.version>採用 Greenwich.SR1
適配 spring 版本爲 org.springframework version:5.1.11

【操作步驟】

去掉:

 1     <dependencyManagement>
 2         <dependencies>
 3             <dependency>
 4                 <groupId>org.activiti.dependencies</groupId>
 5                 <artifactId>activiti-dependencies</artifactId>
 6                 <version>7.1.0.M6</version>
 7                 <scope>import</scope>
 8                 <type>pom</type>
 9             </dependency>
10         </dependencies>
11     </dependencyManagement>

版本依賴推遲到具體的包的引用上,具體爲:

(1)若工程採用多module方式,在 主module(即 root module,也即 工程中的parent模塊)pom.xml 中:

 1     <modules><!-- 示例保留了4個module -->
 2         <module>activiti-server</module>
 3         <module>schedule-server</module>
 4         <module>eureka-server</module>
 5         <module>common-server</module>
 6     </modules>
 7     
 8     <parent>
 9         <groupId>org.springframework.boot</groupId>
10         <artifactId>spring-boot-starter-parent</artifactId>
11         <version>2.1.10.RELEASE</version><!--org.springframework version:5.1.11-->
12         <relativePath/> <!-- lookup parent from repository -->
13     </parent>
14     
15     <dependencyManagement>
16         <dependencies>
17             <dependency>
18                 <groupId>org.springframework.cloud</groupId>
19                 <artifactId>spring-cloud-dependencies</artifactId>
20                 <version>${spring-cloud.version}</version>
21                 <scope>import</scope>
22                 <type>pom</type>
23             </dependency>
24         </dependencies>
25     </dependencyManagement>

(2)在 各子module的 pom.xml 中

1         <dependency>
2             <groupId>org.springframework.boot</groupId>
3             <artifactId>spring-boot-starter-web</artifactId>
4         </dependency>
5         <dependency>
6             <groupId>org.springframework.boot</groupId>
7             <artifactId>spring-boot-starter-data-jpa</artifactId>
8         </dependency>
9         <!-- …… 其他springboot依賴 -->

(3)其中在 activiti-server 服務板塊 pom.xml 如此:

 1         <properties>
 2             <activiti-dependencies.version>7.1.0.M6</activiti-dependencies.version>
 3         </properties>
 4         <dependencies>
 5             <dependency>
 6                 <groupId>org.activiti</groupId>
 7                 <artifactId>activiti-spring-boot-starter</artifactId>
 8                 <version>${activiti-dependencies.version}</version>
 9             </dependency>
10             <!-- Activiti生成流程圖 -->
11             <dependency>
12                 <groupId>org.activiti</groupId>
13                 <artifactId>activiti-image-generator</artifactId>
14                 <version>${activiti-dependencies.version}</version>
15             </dependency>
16             
17             <!-- …… 其他springboot依賴 -->
18         </dependencies>

【敬告】

版本選擇時,需做兼容性測試,使用成熟的版本,不要輕易調整,尤其處於基礎位置的更要慎重。在版本升級中,會出現嚴重的兼容性問題,而且容易引起,牽一髮而動全身,甚至造成不可逆轉的遺恨(有些問題的暴露不是立即現象的,這就更加不好把控了)。

 

問題虐我千百遍,再也別見!

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章