Your class A
declaration is compiled into this one:
class A {
@Autowired
SomeType one;
String two;
int three;
public A() {
this.two = one.someMethod();
}
}
So when Spring creates an instance of A
to inject an instance of SomeType
into it, it calls the A
's default constructor and hence you get an NPE
.