pulic Class MyBean{
private String name;
@Required
public void setName(String name){
this.name=name
}
}
使用JDK5的Annotation功能,可以用红色部分代替在配置文件中使用dependency-check来进行DI检查
使用这个功能需要在配置文件中定义Bean:
<bean id="requiredChecker" class="rog.springframework.beans.factory.annotation.RequiredAnnotationBean
PostProcessor"/>
可以避免在运行时时的NullPointerException