今天在idea中使用 @Autowired一直都不能运行,首先爆出的错误是空指针异常
然后想到了在ecliplse中使用@Autowired在junit4环境下会配置
@RunWith() @ContextConfiguration()
但却发现是爆红的,就猜想是否是包没引入,结果才发现maven项目中没有引入spring-test,于是便引入了该包
但结果发现还是不能是用@RunWith() @ContextConfiguration(),再次排查在maven引入包的时候是否配置有问题,
结果发现spring-test中有<scope></scope>,把这个去掉就成功了