Is it possible to convert the following XML configuration to an annotation based one?
<bean id="myBean" class="my.package.MyBeanClass" scope="prototype" />
I'm using Spring 2.5.6.
Is it possible to convert the following XML configuration to an annotation based one?
<bean id="myBean" class="my.package.MyBeanClass" scope="prototype" />
I'm using Spring 2.5.6.
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")
@Repository
public class MovieFinderImpl implements MovieFinder {
// ...
}
In Spring 5, You can use as follows
@Component("myBean")
@Scope("prototype")
public class MyBeanClass{//your logics}