Activiti7+ SpringBoot+SpringMVC 开发
添加 Controller 类
代码如下:
(图片来源网络,侵删)
@RestController public class MyController { @Autowired private ProcessRuntime processRuntime; @Autowired private TaskRuntime taskRuntime; @Autowired private SecurityUtil securityUtil; }
实现任务完成
@RequestMapping("testTask") public void testTask() { Page taskPage = taskRuntime.tasks(Pageable.of(0, 10)); if (taskPage.getTotalItems() > 0) { for (Task task : taskPage.getContent()) { taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(task.getId()).build()); System.out.println("任务:" + task); taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(task.getId()).build()); } } Page taskPage2 = taskRuntime.tasks(Pageable.of(0, 10)); if (taskPage2.getTotalItems() > 0) { System.out.println("任务:" + taskPage2.getContent()); } }
编写 SpringBoot 启动类
@SpringBootApplication(exclude = SecurityAutoConfiguration.class) public class ActvitiApplication { private Logger logger = LoggerFactory.getLogger(ActvitiApplication.class); public static void main(String[] args) { SpringApplication.run(ActvitiApplication.class, args); } @Bean public Connector testConnector() { return integrationContext -> { logger.info("我被调用啦~~"); return integrationContext; }; } }
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。