自动装配类的新实例 [英] New instance from autowired class

查看:60
本文介绍了自动装配类的新实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
每次都获取引用bean的新bean实例

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?

我已经研究了会话,请求,原型,@ resource.似乎没有一个能提供理想的效果.

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

推荐答案

使用@Scope("prototype")

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

这篇关于自动装配类的新实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆