赞
踩
提示:这里可以添加本文要记录的大概内容:
例如:随着人工智能的不断发展,机器学习这门技术也越来越重要,很多人都开启了学习机器学习,本文就介绍了机器学习的基础内容。
提示:以下是本篇文章正文内容,下面案例可供参考
简述:Activiti是基于Apache许可的开源BPM平台,创始人Tom Baeyens原是JBPM架构师,可以理解为与JBPM出自同一祖师爷。它提供了Eclipse插件,开发可以通过插件直接绘制业务流程图。基于Spring,ibatis等框架,并在此之上构建了非常清晰的开发框架。是由Alfresco软件发布的业务流程管理(BPM)框架,它是覆盖了业务流程管理、工作流、服务协作等领域的一个开源的、灵活的、易扩展的可执行流程语言框架。 本文基于Activiti7的Activiti Core,基于Spring Boot做简单学习总结。(Activiti最新版本向微服务这边靠齐了,并分Activiti Core与Activiti Cloud两块,Activiti Cloud还没研究)
<properties> <java.version>1.8</java.version> <activiti.version>7.0.0.SR1</activiti.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.2</version> </dependency> <!-- 阿里 druid 数据源 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.16</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.54</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.18</version> <scope>provided</scope> </dependency> <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.16</version> </dependency> <dependency> <groupId>com.hh</groupId> <artifactId>user-service-api</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>org.activiti</groupId> <artifactId>activiti-spring-boot-starter</artifactId> <version>${activiti.version}</version> <exclusions> <exclusion> <groupId>org.activiti.core.common</groupId> <artifactId>activiti-spring-identity</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel</artifactId> <version>2.1.6</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>20.0</version> <scope>compile</scope> </dependency> </dependencies>
package com.hh.userserviceactiviti.config; import org.activiti.engine.*; import org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import javax.sql.DataSource; @Configuration public class ActivitiConfig { @Autowired private DataSource dataSource; @Bean public StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration() { StandaloneProcessEngineConfiguration processEngineConfiguration = new StandaloneProcessEngineConfiguration(); processEngineConfiguration.setDataSource(dataSource); processEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE); processEngineConfiguration.setAsyncExecutorActivate(false); return processEngineConfiguration; } @Bean @Primary public ProcessEngine buildProcessEngine() { return standaloneProcessEngineConfiguration().buildProcessEngine(); } @Bean public RepositoryService repositoryService() { return buildProcessEngine().getRepositoryService(); } @Bean public RuntimeService runtimeService() { return buildProcessEngine().getRuntimeService(); } @Bean public TaskService taskService() { return buildProcessEngine().getTaskService(); } @Bean public HistoryService historyService() { return buildProcessEngine().getHistoryService(); } }
package com.hh.userserviceactiviti.config; import com.google.common.collect.ImmutableList; import org.activiti.api.runtime.shared.identity.UserGroupManager; import org.activiti.engine.impl.history.HistoryLevel; import org.activiti.spring.SpringAsyncExecutor; import org.activiti.spring.SpringProcessEngineConfiguration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.transaction.PlatformTransactionManager; import javax.sql.DataSource; import java.util.List; @Configuration public class WorkFlowConfig { @Autowired private DataSource dataSource; //高版本需要手动填写,所以需要显示声明,并且交个Spring维护和管理。 @Primary @Bean public UserGroupManager userGroupManager() { return new UserGroupManager() { @Override public List<String> getUserGroups(String s) { return ImmutableList.of("指定用户归属组"); } @Override public List<String> getUserRoles(String s) { return null; } @Override public List<String> getGroups() { return null; } @Override public List<String> getUsers() { return null; } }; } @Bean public SpringProcessEngineConfiguration springProcessEngineConfiguration(PlatformTransactionManager transactionManager) { SpringProcessEngineConfiguration springProcessEngineConfiguration = new SpringProcessEngineConfiguration(); springProcessEngineConfiguration.setDataSource(dataSource); springProcessEngineConfiguration.setTransactionManager(transactionManager); SpringAsyncExecutor springAsyncExecutor = new SpringAsyncExecutor(); springAsyncExecutor.setTaskExecutor(threadPoolTaskExecutor()); springProcessEngineConfiguration.setAsyncExecutor(springAsyncExecutor); springProcessEngineConfiguration.setDatabaseSchemaUpdate("true"); springProcessEngineConfiguration.setUserGroupManager(userGroupManager()); springProcessEngineConfiguration.setHistoryLevel(HistoryLevel.FULL); springProcessEngineConfiguration.setDbHistoryUsed(true); return springProcessEngineConfiguration; } @Primary @Bean public ThreadPoolTaskExecutor threadPoolTaskExecutor() { ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); threadPoolTaskExecutor.setCorePoolSize(10); threadPoolTaskExecutor.setMaxPoolSize(30); threadPoolTaskExecutor.setKeepAliveSeconds(500); threadPoolTaskExecutor.setQueueCapacity(500); threadPoolTaskExecutor.initialize(); return threadPoolTaskExecutor; } }
server: port: 7777 spring: application: name: user-service-activiti datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.cj.jdbc.Driver //我这边数据库的驱动是8.0以上的。 username: root password: root url: jdbc:mysql://数据库ip地址:3306/activiti?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true activiti: database-schema-update: true // 表示能够自动创建数据库中的表 history-level: full // 表示创建所有的表 db-history-used: true //使用记录表 mybatis: mapper-locations: mappers/*.xml logging: level: com.ascendant: debug
人生物语:对人生正确的态度是:执著地对待,紧紧地把握,但不能抓得过死,松不开手。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。