1. 程式人生 > >關於@Component下@Autowired注入為null的問題

關於@Component下@Autowired注入為null的問題

關於@Component下@Autowired注入為null的問題@TOC

@Component
public class TimingTaskController{
    public static TimingTaskController timingTaskController;
    @Autowired
	private OrderService orderService;
	
    @PostConstruct
    public void init() {
    	timingTaskController = this;
    	timingTaskController.orderService = this.orderService;
    }
    //呼叫的時候
    timingTaskController.orderService.*****************
}

只是一個解決方法,不建議使用,先填坑吧