I have a peculiar requirement to call Parent class PostContruct instead of child class
import javax.annotation.PostConstruct;
public class Parent {
public Parent(){
System.out.println("In parent contructor");
}
@PostConstruct
public void test(){
System.out.println("In parent post construct");
// call the child's class method
this.test()
}
}
import org.springframework.stereotype.Service;
@Service("Child")
public class Child extends Parent{
public void test(){
System.out.println("In child post construct method");
}
}
So using Spring's service annotation child class gets loaded , Using PostContruct annotation the child's class test method is called , But our requirement is to call parent's class from where we can call the child's class test method .
Is there any way to achieve the same , We don't want to introduce new methods or change method logic