在Spring中,我们可以使用@Scope注解来声明Bean的作用域,常见的作用域有singleton和prototype。例如:
@Component @Scope("singleton") public class MySingletonBean