@AutoWired 出现空指针异常

添加以下设置:
@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/spring/root-context.xml",
"file:src/main/webapp/WEB-INF/spring/appServlet/controllers.xml",
"file:src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml" })

推荐阅读更多精彩内容