如何将camunda表转移到另一个模式

时间:2018-08-17 06:38:19

标签: spring-boot camunda

我正在将camunda工作流程引擎与springBoot一起使用。 但是当我使用camunda的默认配置启动应用程序时。 camunda将在我的业务模式上创建很多表。 问题是如何让camunda将自己的表创建到另一个模式。

我尝试将camunda.bpm.database.schema-name配置为另一个架构名称,但这不起作用。

有人可以帮我吗?

3 个答案:

答案 0 :(得分:1)

我已经从camunda论坛上得到了答案。

这是来自camunda论坛的get的答案。

  

如果要使用其他架构,则必须创建   数据库表由您自己决定。它只能在   默认架构。此外,您必须在   配置。

这里是the solution link

答案 1 :(得分:0)

您可以尝试更改process.xml配置文件中的 databaseTablePrefix 属性。

来源:Process Engine Configuration

答案 2 :(得分:0)

您可以使用任何名称(例如“ camunda”)创建数据库用户,然后将此代码添加到application.yml

 camunda.bpm:
    job-execution-enabled:  true
    history-level: full
    auto-deployment-enabled: true
    id-generator: strong
    checkProcessDefinitions: true
    deployment-resource-pattern:  classpath:/process/**/*.bpmn
    dataSource:
      schema-update: true
      schema-name: camunda
      jdbcUrl: jdbc:oracle:thin:@192.168.250.134:1521:TESTDB
      username: camunda
      password: camunda

然后添加此类

package org.vahidAlizadeh.service;
import java.io.IOException;
import java.sql.SQLException;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.camunda.bpm.engine.impl.cfg.IdGenerator;
import org.camunda.bpm.engine.impl.persistence.StrongUuidGenerator;
import org.camunda.bpm.engine.spring.ProcessEngineFactoryBean;
import org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration;
import org.camunda.bpm.engine.spring.SpringProcessEngineServicesConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Profile;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jndi.JndiTemplate;
import org.springframework.transaction.PlatformTransactionManager;
@Configuration
@Import( SpringProcessEngineServicesConfiguration.class )
public class CamundaConfiguration  {
    @Value("${spring.camunda.bpm.history-level}")
    private String historyLevel;


    @Autowired
    private ResourcePatternResolver resourceLoader;



   @Bean
  // @ConfigurationProperties(prefix="spring.camunda.bpm")
   public SpringProcessEngineConfiguration processEngineConfiguration() throws 
   IOException {
    SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();

    config.setDataSource(camundaDataSource());
    config.setDatabaseSchemaUpdate("true");

    config.setTransactionManager(transactionManager());
    config.setHistory(historyLevel);

    config.setJobExecutorActivate(false);
    config.setMetricsEnabled(false);
    config.setJdbcBatchProcessing(false);
    // deploy all processes from folder 'processes'classpath:/process/*.bpmn
    Resource[] resources = resourceLoader.getResources("classpath:/process/**/*.**");
    config.setDeploymentResources(resources);

    StrongUuidGenerator ss=new StrongUuidGenerator();
    config.setIdGenerator(ss );
    System.err.println("start resource address");
    for (Resource resource : resources) { 
        System.out.println(resource.getFilename());
    }
    return config;
  }

  @Bean                                                                
  public PlatformTransactionManager transactionManager() {
    return new DataSourceTransactionManager(camundaDataSource());
  }
  @Bean(name="camundaBpmDataSource")
    @ConfigurationProperties(prefix="spring.camunda.bpm.dataSource")
    @Profile("dev")
    public DataSource camundaDataSource() {
        System.out.println("spring.camunda.bpm.dataSource");
        return DataSourceBuilder.create().build();
   }
  @Bean(name = "camundaBpmDataSource")
    @Profile("prod")
    public DataSource jndiDataSource() throws SQLException, NamingException {
        JndiTemplate jndi = new JndiTemplate();
        DataSource dataSource = (DataSource) jndi.lookup("camunda");
        return dataSource;
    }
  @Bean
  public ProcessEngineFactoryBean processEngine() throws IOException {
    ProcessEngineFactoryBean factoryBean = new ProcessEngineFactoryBean();
    factoryBean.setProcessEngineConfiguration(processEngineConfiguration());
    return factoryBean;
  }

 }