@Autowired Spring


I wonder if I can use (is it necesarry?) @Autowired annotation for dependency injection in Cuba or it is replaced with specific Cuba API like metadata.create (Class…) or @Injection?

public class A{
private B b;
         public void setB(B b){

Best Regards,

You can use them both, @Autowired and @Inject are almost interchangeable in CUBA applications. For instance, you may use @Autowired to specify that the required dependency is optional.

public class FooService {
    @Autowired(required = false)
    private FooDAO dataAccessor; 
1 Like

Than you!