项目中经常出现循环注入,循环依赖问题,
方式一:现在提供一个工具类,类用Spring中的aware
实现获取bean对象
Spring中的Aware接口是很强大的,是对Spring中的感知接口,一般实现这个接口,可以获取Spring中的容器中的实例。
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import java