@Autowired private ZeebeClient client not working

package com.gadgeon.invoice.automation.service;

import io.camunda.zeebe.client.api.response.ProcessInstanceEvent;
import io.camunda.zeebe.client.ZeebeClient;

import com.gadgeon.invoice.automation.entities.Project;
import com.gadgeon.invoice.automation.repositories.ProjectRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProjectServiceImpl {

    @Autowired
    private ZeebeClient client;
    @Autowired
    private ProjectRepository projectRepository;

    public void saveProject(Project project) {
        ProcessInstanceEvent abc = client.newCreateInstanceCommand()
                .bpmnProcessId("customer_p")
                .latestVersion()
                .send().join();
        System.out.println("pinstance:"+abc.getProcessInstanceKey()+"pdefine:"+abc.getProcessDefinitionKey()+"bpmnpid"+abc.getBpmnProcessId());
    }
}

@Autowired
private ZeebeClient client;
not working
Parameter 0 of constructor in ProjectServiceImpl required a bean of type ‘io.camunda.zeebe.client.ZeebeClient’ that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type ‘io.camunda.zeebe.client.ZeebeClient’ in your configuration.

Process finished with exit code 1

Hey @savi003 :wave:
Have you added @EnableZeebeClient to your application class?
Best,
Thomas

yes i have added @EnableZeebeClient

Hmm :thinking:
Maybe you can peak at this example project of mine:

In there I use this to start a process instance. Might be a little older version of spring-zeebe though that I am using.

@Component
public class ProcessStarter {

    private static Logger log = LoggerFactory.getLogger(ExamplesApplication.class);

    @Autowired
    private ZeebeClientLifecycle client;

    @Scheduled(fixedRate = 5000L)
    public void startProcesses() {
        if (!client.isRunning()) {
            return;
        }

        final ProcessInstanceEvent event =
                client
                        .newCreateInstanceCommand()
                        .bpmnProcessId("Process_MessageCorrelation")
                        .latestVersion()
                        .variables("{\"businessKey\": \"" + UUID.randomUUID().toString() + "\",\"b\": \"" + new Date().toString() + "\"}")
                        .send()
                        .join();

        log.info("started instance for workflowKey='{}', bpmnProcessId='{}', version='{}' with workflowInstanceKey='{}'",
                event.getProcessDefinitionKey(), event.getBpmnProcessId(), event.getVersion(), event.getProcessInstanceKey());
    }
}

Let me know if this works for you! :slight_smile:
Best,
Thomas