I am working on a class C in which I am trying to use an autowired Logger field within one of its methods. Now, I have a method foo in Class A which extends Class B. Class A does not autowire log field, but it's base class B Does. Logger is an interface with no annotation applied. log object works properly on A foo method but is null on Class C.
Class C {
@autowired
Logger log;
void bar (){
log.info("oqoqoq"); //log is null
}
}
interface Logger{
//methods
}
Class B{
@autowired
Logger log;
}
class A extends B{
void foo(){
log.info("ksksks"); //log is ok
C obj = new C();
obj.bar();
}
}
What could be the reason? I do not explicitly create a Logger object as you might be suspecting.
Thanks.