I followed this example: https://github.com/camunda/camunda-bpm-spring-boot-starter/tree/master/examples/camunda-spring-boot-starter-example-simple
when i access the taskService in this class:
@Component
public class TaskHelper {
private final Logger logger = getLogger(this.getClass());
@Autowired
private RuntimeService runtimeService;
@Autowired
private TaskService taskService;
private String processInstanceId;
@EventListener
public void notify(final ContextRefreshedEvent unused) {
processInstanceId = runtimeService.startProcessInstanceByKey("Sample").getProcessInstanceId();
logger.info("started instance: {}", processInstanceId);
List<Task> task = taskService.createTaskQuery().processInstanceId(processInstanceId).list();
logger.info("completed task: {}", task.get(0).getName());
taskService.complete(task.get(0).getId());
logger.info("completed task: {}", task);
// now jobExecutor should execute the async job
}
public String getProcessInstanceId() {
return processInstanceId;
}
its working fine. but how i would access the TaskService in a @RestController class?
i tried like this:
@RestController
public class TaskController {
@Autowired
TaskService taskService;
@RequestMapping(value = "/tasklist")
public String taskList(@RequestParam(value = "name", defaultValue = "all") String name) {
taskService.createTaskQuery().list();
return "Task: ";
}
}
but my taskService is always null. What is the right way to access it in RestController class?