what is none scope bean and when to use it?

后端 未结 3 2019
深忆病人
深忆病人 2020-11-29 09:34

could some explain what a none scope is and purpose of it?

Suppose if i have a bean in

request scope as r1

session scope as s1

application scope a         


        
3条回答
  •  借酒劲吻你
    2020-11-29 09:59

    @NoneScoped would be beneficial in the following scenario.

    Assume that we have to inject the same bean in two different scoped beans, we can mark that bean as @NoneScoped. Say a bean BeanOne with @NoneScoped can be easily injected in any bean with any scope like @Request or @Session.

    Without using @NoneScoped for BeanOne, we may have to duplicate the bean with different scopes and inject them accordingly.

提交回复
热议问题