Spring Scope注释值 [英] Spring Scope annotation value

查看:131
本文介绍了Spring Scope注释值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring框架是否提供String常量来替换下面示例注释中的prototype字符串文字值?

Does the Spring framework provide String constants to replace the "prototype" string literal value in the example annotation below?

@Service
@Scope("prototype")
public class CustomerService 
{
......
}

谢谢!

推荐答案

您可以使用范围Spring的 BeanDefinition 中的常量:

You can use the scope constants from Spring's BeanDefinition:


  • SCOPE_SINGLETON

  • SCOPE_PROTOTYPE

例如

@Scope(BeanDefinition.SCOPE_PROTOTYPE)

这篇关于Spring Scope注释值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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