New instance from autowired class [duplicate]

陌路散爱 提交于 2019-12-13 02:58:45

问题


Possible Duplicate:
getting new bean instances of referencing beans every time

What is a very simple way to get a new instance of an autowired class every time?

I've explored session, request, prototype, @resource. None seem to provide the desired effect.


回答1:


Use @Scope("prototype")

@Service
@Scope("prototype")
public class YourService{}


来源:https://stackoverflow.com/questions/14388480/new-instance-from-autowired-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!