@Autowired @Inject @ComponentImport and @Scanned

Hey Dev Community,
I am trying @Inject my own classes. 1st Class injects multiple classes created by me.
The problem is that the code below sometimes throw the error below and sometimes it just works. Tried multiple times but haven’t able to figure out the exact reason why its happening.

 No qualifying bean of type [com.IDA] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

Code looks like -
Class1 (Base Class)

@JiraComponent
public class SMImpl implements SM {

    private static final Logger log = Logger.getLogger(SMImpl.class);
//All these are my defined components
    private static final JM jM = new JM();
    private final IDA iDA;
    private final AMMA aMMA;
    private final ORH oRH;
    private final IU iU;
    private final MH mH;

    @Inject
    public SMImpl(IDA iDA,
                           AMMA aMMA,
                           ORH oRH,
                           IU iU,
                           MH mH) {
        this.iDA = iDA;
        this.aMMA= aMMA;
        this.oRH = oRH;
        this.iU = iU;
        this.mH = mH;
    }

    /**

Class 2 (IDA.class)-
Class which uses injects a Jira manager class using @ComponentImport never fails(works perfectly with my own componenets also)

@Scanned //This class exist in an external jar which i have created to reduce redundancy
@JiraComponent
public class IUImpl implements IU {

    private static final Logger log = Logger.getLogger(IUImpl.class);
    private final CustomFieldManager customFieldManager;
    private final CommentManager commentManager;

    @Inject
    public IUImpl(@ComponentImport CustomFieldManager customFieldManager,
                         @ComponentImport CommentManager commentManager){
        this.customFieldManager = customFieldManager;
        this.commentManager = commentManager;
    }

Class 3-
Inject into class 1
Below is the problematic code, which has a 50% chance of working.

@Scanned //This class exist in an external jar which i have created to reduce redundancy
@JiraComponent
public class IDAImpl implements IDA {

    private static final Logger log = Logger.getLogger(IDA.class);
    private final IU iU;

    @Inject
    public IDAImpl(IU iU){
         this.iU = iU ;
}

Note The same code starting working when i ran atlas-package and reinstalled.

1 Like