由於spring加載順序的問題,applicationcontext.getbean由於配置跑了一遍後bean已經建立好了,bean都成功織入。因此可以經過這個方法獲得bean。可是你用普通的測試類是沒有跑過配置,須要用spring整合的junit4spring