开发者

Specify scope with in xml free configuration

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜