java - Spring 4. does getBeanFromClass trigger bean's constructor for prototype beans? -


spring 4. getbeanfromclass() trigger bean's constructor prototype beans? if so, should careful calling function, right? in code getbeanfromclass this:

public static <t> t getbeanfromclass(class<t> abeanclass) throws beansexception {         return getapplicationcontext().getbean(abeanclass);     } 

thanks

i'm assuming method. care applicationcontext#getbean(class) (which beanfactory#getbean(class)) method. javadoc states

return bean instance uniquely matches given object type, if any.

so, yes, returns instance. prototype beans, it'll return newly created instance every time.

do have careful? depends entirely on you're doing. if need prototype bean instance, need use (if you're working applicationcontext directly).


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -