Maven Settings (IDEA 2020 required)

There are many problems with Importing Maven project cannot resolve

When importing the open source Maven project in IDEA2020.1, the offline mode is selected by default, which is shown in the red box in the following figure. Modify the Settings, uncheck set offline mode, as shown, resynchronize, and import Maven dependencies

Import the Settings again

Refer to blogsBlog.csdn.net/weixin_3997…

Pom depends on

`

<dependency> <groupId>org.activiti</groupId> <artifactId>activiti-spring-boot-starter-basic</artifactId> The < version > 6.0.0 < / version > <! > <exclusions> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> </exclusion> </exclusions> </dependency> <! <dependency> <groupId>com.fasterxml.uuid</groupId> <artifactId> Java -uuid-generator</artifactId> The < version > 3.1.4 < / version > < / dependency > <! -- activiti end --> `Copy the code

Springboot boot options

/ / need to startup out of spring SecurityAutoConfiguration conflict with class, Is not used in my project @ SpringBootApplication (exclude = org. Activiti. Spring. The boot. SecurityAutoConfiguration. Class, scanBasePackages = "io.geekidea.springbootplus.activiti") public class ApplicationTestApplication { }Copy the code

The config configuration

import io.geekidea.springbootplus.framework.activiti.config.CustomActivitiEventListener; import org.activiti.engine.TaskService; import org.activiti.engine.delegate.event.ActivitiEventListener; import org.activiti.engine.impl.persistence.StrongUuidGenerator; import org.activiti.engine.impl.persistence.deploy.Deployer; import org.activiti.engine.impl.rules.RulesDeployer; import org.activiti.spring.SpringProcessEngineConfiguration; import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; @Component public class ActivitiConfiguration implements ProcessEngineConfigurationConfigurer { @Override public void Configure (SpringProcessEngineConfiguration processEngineConfiguration) {/ * small pit: The listener is not added to spring management. Some activiti service injection did not enter * / TaskService TaskService = processEngineConfiguration. GetTaskService (); CustomActivitiEventListener myEventListener = new CustomActivitiEventListener(taskService); ProcessEngineConfiguration. SetActivityFontName (" tahoma "); ProcessEngineConfiguration. SetLabelFontName (" tahoma "); ProcessEngineConfiguration. SetAnnotationFontName (" tahoma "); List<Deployer> customPostDeployers = new ArrayList<>(); customPostDeployers.add(new RulesDeployer()); processEngineConfiguration.setCustomPostDeployers(customPostDeployers); processEngineConfiguration.setIdGenerator(new StrongUuidGenerator()); List<ActivitiEventListener> eventListeners = new ArrayList<>(); processEngineConfiguration.setEventListeners(eventListeners); }}Copy the code

Listening to the class

import org.activiti.engine.TaskService; import org.activiti.engine.delegate.event.ActivitiEvent; import org.activiti.engine.delegate.event.ActivitiEventListener; import org.activiti.engine.task.Task; import org.springframework.util.CollectionUtils; import java.util.List; public class CustomActivitiEventListener implements ActivitiEventListener { private TaskService taskService; public CustomActivitiEventListener(TaskService taskService) { this.taskService = taskService; } /** * Called when an event has been fired * * @param event the event */ @Override public void onEvent(ActivitiEvent Event) {switch (event.getType()) {case TASK_COMPLETED: system.out.println (" There is a task executor... ); System.out.println(event.getProcessInstanceId()); List<Task> list = taskService.createTaskQuery() .processInstanceId(event.getProcessInstanceId()) .active() .list(); if (! CollectionUtils.isEmpty(list)) { for (Task task : list) { System.out.println(task.getName()); System.out.println(task.getAssignee()); }} break; case TASK_ASSIGNED: break; case TASK_CREATED: break; default: // System.out.println("Event received: " + event.getType()); } } /** * @return whether or not the current operation should fail when this listeners execution throws an exception. */  @Override public boolean isFailOnException() { return false; }}Copy the code