today,i learned that we could use spring's @AutoWired annotation to complete auto-injection, @AutoWired could be used in many conditions ,like
@AutoWired
public void setInstrument(Instrument instrument){
this.instrument = instrument;
}
but we can also put the @AutoWired
on a private field,like this
@AutoWired
private Instrument instrument;
i was wondering ,how could spring inject an object into a private field,i know we could use reflection of java to get some meta data,when i use reflection to set a object on a private field ,here comes a problem ,following is the stacktrace
java.lang.IllegalAccessException: Class com.wire.with.annotation.Main can not access a member of class com.wire.with.annotation.Performer with modifiers "private"
some body can explain it ? why spring could inject an object into a private field with no setter method . thanks a lot