How to override the behavior of Spring @Autowired

后端 未结 3 1170
北荒
北荒 2020-12-19 05:06

A little background:

I am Using Spring 2.5, and specifically Spring IOC and annotations.

I am using @Autowired in my code (the Autowiring is don

3条回答
  •  一个人的身影
    2020-12-19 05:58

    Use ReflectionTestUtils to manually set the Mock in place of the autowired dependency (for that purpose your mock must not be spring managed, so that no ambiguity exists)

提交回复
热议问题