服务任务中的Flowable委托表达式不起作用

问题描述

我正在使用的可流通版本是6.4.1。

@Component

public class MyClass implements JavaDelegate {

    @Autowired
    private MySampleService mySampleService;

    @Override
    public void execute(DelegateExecution delegateExecution){
        sampleService.doSoMetask();
    }
}

在这里,将为类MyClass创建myClass bean。因此,在bpmn中,我可以像flowable:delegateExpression =“ $ {myClass}”一样使用它。

但是我遇到了错误

"unkNown property used in expression: ${myClass}"

如果没有委托表达式,mySampleService将为null。

有什么建议吗?

解决方法

有两种配置可流动的方法:

  1. 手动-使用“常规” Spring时,您还需要注册ProcessEngineFactoryBean。这将使用engineConfiguration并创建一个可以访问表达式管理器的SpringExpressionManager(https://github.com/flowable/flowable-engine/blob/master/modules/flowable-spring/src/main/java/org/flowable/spring/SpringExpressionManager.java)。
  2. SpringBoot,提供开箱即用的配置。只需提供所需的bean,例如DataSource,AsyncExecutor等(根据您的情况),然后使用Spring Boot负责其余的工作。