0

I want to Inject one interface in another serviceimpl.

@Service
class ServiceA implements InterfaceA {
 //// 
}

@Service
class ServiceB implements InterfaceB {
  @Inject
  private InterfaceA obj; // returning null
}

The above structure returning null when I am trying to use InterfaceA in ServiceB. I even tried with @Lazy like below,

  @Inject
  @Lazy
  private InterfaceA obj; // returning null
Tamil.S
  • 403
  • 3
  • 14
  • Try with @Autowired. – pringi Mar 03 '22 at 14:59
  • An autowired field in spring cannot be `null`, your application will fail to start. Which means you are probably doing a `new ServiceB()` yourself or at least outside the scope of Spring. – M. Deinum Mar 03 '22 at 15:05

0 Answers0