Create prototype scoped Spring bean with annotations?
You can use the @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
annotation.
@Service@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)public class CustomerService { // ...}
As of the current spring version 4.3.2
, we can use @Scope("prototype") annotation.
@Scope("prototype")@Repositorypublic class MovieFinderImpl implements MovieFinder { // ...}
In Spring 5, You can use as follows
@Component("myBean")
@Scope("prototype")
public class MyBeanClass{//your logics}