You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot Maven依赖部署Flowable时访问决策表失败问题

解决Flowable Spring Boot中决策表找不到的问题

1. 确保依赖版本一致且完整

你已添加flowable-spring-boot-starter-dmn,但必须保证它和flowable-spring-boot-starter-rest的版本完全一致,避免版本冲突导致DMN引擎无法正常初始化。示例Maven依赖:

<dependency>
    <groupId>org.flowable</groupId>
    <artifactId>flowable-spring-boot-starter-rest</artifactId>
    <version>6.8.0</version> <!-- 替换为你的实际版本 -->
</dependency>
<dependency>
    <groupId>org.flowable</groupId>
    <artifactId>flowable-spring-boot-starter-dmn</artifactId>
    <version>6.8.0</version> <!-- 版本必须与上方保持一致 -->
</dependency>

2. 配置DMN自动部署参数

在application.properties中添加DMN相关配置,确保Flowable能扫描到resources/processes下的DMN文件并自动部署:

# 指定DMN文件扫描路径,与BPMN同目录
flowable.dmn.deployment-resource-location=classpath*:/processes/**/*.dmn
# 开启自动创建决策表定义
flowable.dmn.deployment-auto-create-definitions=true

如果需要同时扫描BPMN和DMN,也可以合并配置:

flowable.dmn.deployment-resource-location=classpath*:/processes/**/*.dmn,classpath*:/processes/**/*.bpmn20.xml

3. 验证DMN是否成功部署

通过以下方式确认决策表已被正确部署:

  • 调用Flowable REST接口:发送GET /dmn-repository/decisions请求,查看返回结果中是否包含你的决策表key
  • 代码验证:注入DmnRepositoryService,执行查询判断是否存在目标决策表:
@Autowired
private DmnRepositoryService dmnRepositoryService;

// 在合适的位置执行查询
DecisionDefinition decisionDefinition = dmnRepositoryService.createDecisionDefinitionQuery()
        .decisionKey("<你的决策表key>")
        .singleResult();
if (decisionDefinition == null) {
    // 决策表未部署,需检查扫描配置和文件路径
}

4. 检查BPMN中决策表的引用正确性

确保BPMN流程中的业务规则任务配置的decisionRef是决策表的key(而非文件名或显示名称),且大小写完全匹配。在Flowable建模器中,关联决策表时需确认选择的是key而非其他字段。

5. 手动部署DMN(自动部署失效时)

如果自动扫描仍不生效,可通过配置类手动触发DMN文件部署:

import org.flowable.dmn.api.DmnRepositoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;

import javax.annotation.PostConstruct;
import java.io.IOException;

@Configuration
public class DmnDeploymentConfig {

    @Autowired
    private DmnRepositoryService dmnRepositoryService;

    @PostConstruct
    public void deployDmnFiles() throws IOException {
        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        Resource[] dmnResources = resolver.getResources("classpath:/processes/**/*.dmn");
        for (Resource resource : dmnResources) {
            dmnRepositoryService.createDeployment()
                    .addInputStream(resource.getFilename(), resource.getInputStream())
                    .deploy();
        }
    }
}

6. 数据库层面验证

直接查看Flowable数据库表ACT_DMN_DECISION_DEF,确认是否存在目标决策表的记录。若表中无对应数据,说明部署流程未执行,需回到依赖和配置步骤排查问题。

内容的提问来源于stack exchange,提问作者Pent Terry

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 11:32:54