I get a null pointer when I try to access a method in a Spring Bean child class, for example, in class A
below:
new B().methodB();
How can I properly extend Spring Bean and acess the Child Class?
@Component
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS, value = "prototype")
class A {
@Autowired
protected Object objectl
public void methodA() {
new B().methodB();
}
public void doStuff() {
System.out.println("Successfully called...");
}
}
class B extends B {
public void methodB() {
objectl.doStuff();
}
}
UPDATE:
The problem is that I'm trying to to create an Array Objcet of B, something like B[] b = new B[size]
, but I can't figure how to from a Spring Bean.