Overriding an Autowired Bean in Unit Tests

前端 未结 5 722
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 19:09

Is there a simple way I can easily override an autowired bean in specific unit tests? There is only a single bean of every type in the compile classes so it\'s not a problem

5条回答
  •  时光取名叫无心
    2020-12-04 19:25

    You should use spring profiles in order to know what kind of bean you want to use in different contexts.

    http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html

提交回复
热议问题