【直击问题】
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>
【敬告】
版本选择时,需做兼容性测试,使用成熟的版本,不要轻易调整,尤其处于基础位置的更要慎重。在版本升级中,会出现严重的兼容性问题,而且容易引起,牵一发而动全身,甚至造成不可逆转的遗恨(有些问题的暴露不是立即现象的,这就更加不好把控了)。
问题虐我千百遍,再也别见!