真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

如何解決Springboot2.1.x配置Activiti7單獨(dú)數(shù)據(jù)源問(wèn)題

本篇內(nèi)容介紹了“如何解決Springboot2.1.x配置Activiti7單獨(dú)數(shù)據(jù)源問(wèn)題”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

公司主營(yíng)業(yè)務(wù):成都做網(wǎng)站、成都網(wǎng)站制作、移動(dòng)網(wǎng)站開(kāi)發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。成都創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開(kāi)放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來(lái)驚喜。成都創(chuàng)新互聯(lián)推出浮梁免費(fèi)做網(wǎng)站回饋大家。

1|1簡(jiǎn)介

最近基于最新的Activiti7配置了SpringBoot2。

簡(jiǎn)單上手使用了一番。發(fā)現(xiàn)市面上解決Activiti7的教程很少,采坑也比較多,在Activiti6配置數(shù)據(jù)源和Activiti7有所區(qū)別,基于Activiti6在Activiti7里是無(wú)法正常使用的。接下來(lái)讓我們看下區(qū)別。

1|2問(wèn)題

Activiti6多數(shù)據(jù)源配置

6的配置比較簡(jiǎn)單點(diǎn)。

先加入配置:

# activiti 數(shù)據(jù)源spring.datasource.activiti.driver=com.MySQL.jdbc.Driverspring.datasource.activiti.url=jdbc:mysql://10.1.1.97:3311/test-activiti7-db?useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=truespring.datasource.activiti.username=rootspring.datasource.activiti.password=Rtqw123OpnmERspring.datasource.activiti.driverClassName=com.mysql.jdbc.Driver

用@ConfigurationProperties加載以spring.datasource.activiti開(kāi)頭的DataSource。  創(chuàng)建ActivitiConfig繼承AbstractProcessEngineAutoConfiguration方法注入SpringProcessEngineConfigurationbean,調(diào)用AbstractProcessEngineAutoConfiguration#baseSpringProcessEngineConfiguration方法把創(chuàng)建的數(shù)據(jù)源注入。

@Configurationpublic class ActivitiConfig extends AbstractProcessEngineAutoConfiguration { @Bean @ConfigurationProperties(prefix = "spring.datasource.activiti") public DataSource activitiDataSource() {  return DataSourceBuilder.create().build(); } @Bean public SpringProcessEngineConfiguration springProcessEngineConfiguration(   PlatformTransactionManager transactionManager,   SpringAsyncExecutor springAsyncExecutor) throws IOException {  return baseSpringProcessEngineConfiguration(    activitiDataSource(),    transactionManager,    springAsyncExecutor); }}

Activiti6的數(shù)據(jù)源已經(jīng)配置完成,如果是7的話會(huì)發(fā)現(xiàn)

AbstractProcessEngineAutoConfiguration#baseSpringProcessEngineConfiguration方法已經(jīng)不存在了,我們需要產(chǎn)考源碼構(gòu)建方式改造一番。

1|3修復(fù)

Activiti7多數(shù)據(jù)源配置

配置還是要上面的。

創(chuàng)建ActivitiConfig繼承AbstractProcessEngineAutoConfiguration方法注入SpringProcessEngineConfigurationbean。  用@ConfigurationProperties加載以spring.datasource.activiti開(kāi)頭的DataSource

@Configurationpublic class ActivitiConfig extends AbstractProcessEngineAutoConfiguration {  @Bean @ConfigurationProperties(prefix = "spring.datasource.activiti") public DataSource activitiDataSource() {  return DataSourceBuilder.create().build(); }  ...略}SpringProcessEngineConfiguration注入方式改為下面: @Bean @Primary public SpringProcessEngineConfiguration springProcessEngineConfiguration(   PlatformTransactionManager transactionManager,   SpringAsyncExecutor springAsyncExecutor,   ActivitiProperties activitiProperties,   ProcessDefinitionResourceFinder processDefinitionResourceFinder,   @Autowired(required = false) DefaultActivityBehaviorFactoryMappingConfigurer processEngineConfigurationConfigurer,   @Autowired(required = false) List processEngineConfigurators,   UserGroupManager userGroupManager,   DataSource dataSource) throws IOException {  SpringProcessEngineConfiguration conf = new SpringProcessEngineConfiguration();  conf.setConfigurators(processEngineConfigurators);  configureProcessDefinitionResources(processDefinitionResourceFinder,    conf);  conf.setDataSource(dataSource);  conf.setTransactionManager(transactionManager);  if (springAsyncExecutor != null) {   conf.setAsyncExecutor(springAsyncExecutor);  }  conf.setDeploymentName(activitiProperties.getDeploymentName());  conf.setDatabaseSchema(activitiProperties.getDatabaseSchema());  conf.setDatabaseSchemaUpdate(activitiProperties.getDatabaseSchemaUpdate());  conf.setDbHistoryUsed(activitiProperties.isDbHistoryUsed());  conf.setAsyncExecutorActivate(activitiProperties.isAsyncExecutorActivate());  if (!activitiProperties.isAsyncExecutorActivate()) {   ValidatorSet springBootStarterValidatorSet = new ValidatorSet("activiti-spring-boot-starter");   springBootStarterValidatorSet.addValidator(new AsyncPropertyValidator());   if (conf.getProcessValidator() == null) {    ProcessValidatorImpl processValidator = new ProcessValidatorImpl();    processValidator.addValidatorSet(springBootStarterValidatorSet);    conf.setProcessValidator(processValidator);   } else {    conf.getProcessValidator().getValidatorSets().add(springBootStarterValidatorSet);   }  }  conf.setMailServerHost(activitiProperties.getMailServerHost());  conf.setMailServerPort(activitiProperties.getMailServerPort());  conf.setMailServerUsername(activitiProperties.getMailServerUserName());  conf.setMailServerPassword(activitiProperties.getMailServerPassword());  conf.setMailServerDefaultFrom(activitiProperties.getMailServerDefaultFrom());  conf.setMailServerUseSSL(activitiProperties.isMailServerUseSsl());  conf.setMailServerUseTLS(activitiProperties.isMailServerUseTls());  if (userGroupManager != null) {   conf.setUserGroupManager(userGroupManager);  }  conf.setHistoryLevel(activitiProperties.getHistoryLevel());  conf.setCopyVariablesToLocalForTasks(activitiProperties.isCopyVariablesToLocalForTasks());  conf.setSerializePOJOsInVariablesToJson(activitiProperties.isSerializePOJOsInVariablesToJson());  conf.setJavaClassFieldForJackson(activitiProperties.getJavaClassFieldForJackson());  if (activitiProperties.getCustomMybatisMappers() != null) {   conf.setCustomMybatisMappers(     getCustomMybatisMapperClasses(activitiProperties.getCustomMybatisMappers()));  }  if (activitiProperties.getCustomMybatisXMLMappers() != null) {   conf.setCustomMybatisXMLMappers(     new HashSet<>(activitiProperties.getCustomMybatisXMLMappers()));  }  if (activitiProperties.getCustomMybatisXMLMappers() != null) {   conf.setCustomMybatisXMLMappers(     new HashSet<>(activitiProperties.getCustomMybatisXMLMappers()));  }  if (activitiProperties.isUseStrongUuids()) {   conf.setIdGenerator(new StrongUuidGenerator());  }  if (activitiProperties.getDeploymentMode() != null) {   conf.setDeploymentMode(activitiProperties.getDeploymentMode());  }  conf.setActivityBehaviorFactory(new DefaultActivityBehaviorFactory());  if (processEngineConfigurationConfigurer != null) {   processEngineConfigurationConfigurer.configure(conf);  }  return conf; } private void configureProcessDefinitionResources(   ProcessDefinitionResourceFinder processDefinitionResourceFinder,   SpringProcessEngineConfiguration conf) throws IOException {  List procDefResources = processDefinitionResourceFinder    .discoverProcessDefinitionResources();  if (!procDefResources.isEmpty()) {   conf.setDeploymentResources(procDefResources.toArray(new Resource[0]));  } }

1|4常見(jiàn)錯(cuò)誤

在以上配置中可能會(huì)有jdbcUrl is required with driverClassName錯(cuò)誤

解決辦法如下:

# activiti 數(shù)據(jù)源spring.datasource.activiti.driver=com.mysql.jdbc.Driverspring.datasource.activiti.url=jdbc:mysql://10.1.1.97:3311/test-activiti7-db?useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true# url換為jdbc-url 解決jdbcUrl is required with driverClassName錯(cuò)誤# 官方文檔的解釋是:# 因?yàn)檫B接池的實(shí)際類型沒(méi)有被公開(kāi),所以在您的自定義數(shù)據(jù)源的元數(shù)據(jù)中沒(méi)有生成密鑰,而且在IDE中沒(méi)有完成(因?yàn)镈ataSource接口沒(méi)有暴露屬性)。# 另外,如果您碰巧在類路徑上有Hikari,那么這個(gè)基本設(shè)置就不起作用了,因?yàn)镠ikari沒(méi)有url屬性(但是確實(shí)有一個(gè)jdbcUrl屬性)。在這種情況下,您必須重寫您的配置如下:spring.datasource.activiti.jdbc-url=${spring.datasource.activiti.url}spring.datasource.activiti.username=rootspring.datasource.activiti.password=Rtqw123OpnmERspring.datasource.activiti.driverClassName=com.mysql.jdbc.Driver

“如何解決Springboot2.1.x配置Activiti7單獨(dú)數(shù)據(jù)源問(wèn)題”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!


網(wǎng)站標(biāo)題:如何解決Springboot2.1.x配置Activiti7單獨(dú)數(shù)據(jù)源問(wèn)題
當(dāng)前URL:http://weahome.cn/article/ihcisg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部