Unit tests vs integration tests with Spring

前端 未结 7 745
清酒与你
清酒与你 2020-12-07 17:27

I\'m working on a Spring MVC project, and I have unit tests for all of the various components in the source tree.

For example, if I have a controller HomeContr

7条回答
  •  时光说笑
    2020-12-07 18:19

    Use the InitializingBean interface (implements a method "afterPropertiesSet") or specify an init-method for your beans. InitializingBean is typically easier because you don't need to remember to add the init method to your beans.

    Use afterPropertiesSet to ensure everything is injected as non-null, if it is null, throw an Exception.

提交回复
热议问题