Java 静态方法注入service的问题
@Component public class PosCommonUtils{ @Resource private HotelService hotelService; private static PosCommonUtils posCommonUtils; @PostConstruct public void init() { posCommonUtils = this; posCommonUtils.hotelService= this.hotelService; } public static void getList(String code){ posCommonUtils.hotelService.getHotelBaseInfo(code); }
}
//@PostConstruct把需要用的service加载到定义的静态内部对象中 先进行init()方法,在进行@Resource注入