慢来比较快,虚心学技术
思路永远比答案更有价值
问题场景
SpringBoot项目中,activiti某个流程节点需要配置监听器,当前节点任务提交完成之后触发方法更改远程表单的状态,具体流程监听设计如下:
feignClient代码:MyService.java
@FeignClient(value = "xxxxx")
public interface MyService {
/**
* 修改状态
* @param inId
* @return
*/
@PutMapping("/myTest/updateState")
Boolean updateState(@RequestParam("id") Integer id);
}
监听器代码:MyTaskListener.java,此处使用Lombok @AllArgConstructor注解通过全参构造器注入MyService
@AllArgsConstructor
public class MyTaskListener implements TaskListener {
private MyService myService;
/**
* 任务监听修改表单状态
* @param delegateTask 当前执行提交的任务
*/
@Override
public void notify(DelegateTask delegateTask) {
。。。。。//获取到表单id
myService.updateState(id);
}
}
任务提交完成触发监听器的报错信息:couldn't instantiate class com.xxx.activiti.listener.MyTaskListener
2019-04-16 19:01:45.592 ERROR [xxx-activiti,b4057cc762e15e24,b4057cc762e15e24,true] 224 --- [ XNIO-1 task-1] o.a.e.impl.interceptor.CommandContext : Error while closing command context
org.activiti.engine.ActivitiException: Exception while invoking TaskListener: couldn't instantiate class com.xxx.activiti.listener.MyTaskListener
at org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:742)
at org.activiti.engine.impl.persistence.entity.TaskEntity.complete(TaskEntity.java:184)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:52)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:24)
at org.activiti.engine.impl.cmd.NeedsActiveTaskCmd.execute(NeedsActiveTaskCmd.java:59)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.j