转载自:http://blog.csdn.net/cy104204/article/details/51076678

 

一般对于有bean注入的类进行方法单元测试时,会发现bean对象并没有注入进来,对象是null。这种情况可以使用如下方式解决:

 

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/spring/applicationContext.xml" })
public class AOPTest extends AbstractJUnit4SpringContextTests{

   @AutoWired
   private AService aService;

   @Test
   public void test(){
     //TODO 
   }
}

相关文章:

  • 2021-09-26
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2021-08-11
  • 2021-10-07
猜你喜欢
  • 2021-04-21
  • 2022-12-23
  • 2022-12-23
  • 2023-04-10
  • 2021-11-20
  • 2021-07-27
相关资源
相似解决方案