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 {}
精彩评论