报告 <bean> 元素中的 autowire 属性,并建议在可能的情况下显式注入 Bean 属性。

示例:


  public class MyComponent {
    public void setOtherBean(OtherBean bean){...}
  }


<beans> <bean class="beans.OtherBean" id="bar"/> <bean autowire="byType" class="beans.MyComponent"/> // "不必要的自动装配的依赖项" // 建议 "将自动装配的依赖关系设为显式" </beans>

应用快速修复后:


  <beans>
    <bean class="beans.OtherBean" id="bar"/>
    <bean class="beans.MyComponent" id="foo">
      <property name="otherBean" ref="otherBean"/>
    </bean>
  </beans>