Injection issue with spring boot 3 and acitiviti engine

61 views Asked by At

I started a spring boot 3.2 project, where I added the activiti-engine dependency

    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-engine</artifactId>
    </dependency>

And I see this error:

Could not autowire. No beans of 'RuntimeService' type found

When I try to inject the RuntimeService in order to call the startProcessInstanceById method.

I saw many questions similar to mine, but still I couldn't figure out the best alternative or solution.

Any suggestions?

1

There are 1 answers

0
Yousha Aleayoub On

Could not autowire. No beans of 'RuntimeService' type found

This error typically arises when Spring Boot cannot locate a bean of RuntimeService type to inject into the dependent class.

So first ensure that RuntimeService bean is properly configured and available for injection.

Then:

  • You can explicitly define RuntimeService bean in your Spring configuration class using @Bean annotation.
 @Configuration
 public class ActivitiConfig {
 
     @Bean
     public RuntimeService runtimeService() {
         return processEngine().getRuntimeService();
     }
 }
  • Or add the @Service annotation to the RuntimeService class to make it a Spring-managed bean.
 @Service
 public class RuntimeService {
     // Service implementation
 }