2012-10-31 85 views
13

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

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

谢谢!

回答

20

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

  • SCOPE_SINGLETON
  • SCOPE_PROTOTYPE

例如

@Scope(BeanDefinition.SCOPE_PROTOTYPE) 
+0

谢谢!下面是包含它(为别人需要它)Maven的神器: org.springframework \t \t \t 弹簧豆 \t \t \t 3.1.2.RELEASE。这当然在Spring Maven Repository中。 – Marquez