activiti进程配置总是指向h2

uyto3xhc  于 2021-07-13  发布在  Java
关注(0)|答案(3)|浏览(345)

我试图从activiti.cfg.xml中读取processengine,在这里我配置了db2并设置了数据源。但在调试过程中,我可以看到进程配置仍然是h2。另外,在尝试从r运行时服务创建流程示例时,它显示为null。下面是代码

ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml", "processEngineConfiguration")

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
    <property name="databaseType" value="db2" />
    <property name="dataSource" ref="customDataSource" />
 </bean>
 <bean id="dataSourceTarget" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="XXX"></property>
<bean id="customDataSource" class="XXX">
    <property name="targetDataSource"><ref local="dataSourceTarget"/></property>
    <property name="schemaName"><value>XXX</value></property>
</bean>

            RuntimeService runtimeService = processEngine.getRuntimeService();
        processInstance = runtimeService.startProcessInstanceByKey(processDefinitionName, processVariablesMap);

如何将配置更改为db2并获取流程示例?

bfrts1fy

bfrts1fy1#

我想你错过了 buildProcessEngine() ```
ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml", "processEngineConfiguration").buildProcessEngine()

而不是

ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml", "processEngineConfiguration")

2j4z5cfb

2j4z5cfb2#

您需要更改activiti.properties文件中的数据库属性,注解h2配置并指定自己的db配置。这是给activiti enterprise的。。。从你的代码看,你似乎正在使用社区一然后尝试创建独立的进程引擎,而不是使用.xml文件。。。

6l7fqoea

6l7fqoea3#

如果您试图在一个扩展javadelegate的类中创建一个运行时,那么要简单得多。您需要新进程来继承以前的运行时属性。
所以与其这样做

RuntimeService runtimeService = processEngine.getRuntimeService();

您可以获得实际的执行运行时:

public class CreateNewInstance implements JavaDelegate {

    private String processKey;
    private Map<String, Object> variables;

    public void execute(DelegateExecution execution) throws Exception {

        // Load all the variables into the Map
        variables = execution.getVariables();

        RuntimeService runtimeService = execution.getEngineServices()
                .getRuntimeService();
        runtimeService.startProcessInstanceByKey(processKey, variables);

    }
}

希望有帮助。

相关问题