开发者

Specify scope with in xml free configuration

开发者 https://www.devze.com 2023-03-28 02:51 出处:网络
I use AnnotationConfigApplicationContext to configure my application. How I can specif开发者_开发技巧y bean scope using annotations or in other xml-free way?Different Types of scope:

I use AnnotationConfigApplicationContext to configure my application. How I can specif开发者_开发技巧y bean scope using annotations or in other xml-free way?


Different Types of scope:

singleton – Return a single bean instance per Spring IoC container

prototype – Return a new bean instance each time when requested

request – Return a single bean instance per HTTP request. *

session – Return a single bean instance per HTTP session. *

globalSession – Return a single bean instance per global HTTP session. *

XML-Free Way:

@Scope("[scopegoeshere]")
public class myClass {}
0

精彩评论

暂无评论...
验证码 换一张
取 消