Generalize
@Autowired is an instance that can only be injected into the spring container for non-static properties of the class, and the instance that wants to inject static properties into the spring container can be passed in the non-static method marked by @Autowired.
Code demo
@Component
public class SubversionApiWrapper implements CodeApiInterface {
//spring实例本类的bean时,通过setter方法初始化静态成员变量
private static ProjectBiz projectBiz;
//setProjectBiz()方法也不能使用static来修饰,否则不会执行
@Autowired
public void setProjectBiz(ProjectBiz projectBiz) {
SubversionApiWrapper.projectBiz = projectBiz;
}
// 其余代码,省略一万行
}