Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Spring Scope in XML

How can I go about setting the scope:

@Component
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS, value = "prototype")

in XML, instead of using @Scope annotation?

like image 871
Program-Me-Rev Avatar asked Mar 15 '23 16:03

Program-Me-Rev


2 Answers

If you want XML based configuration then you can do it in following way:-

<bean id="YOUR_BEAN_ID" class="YOUR_FULLY_QUALIFIED_CLASSNAME" scope="prototype">
    <aop:scoped-proxy proxy-target-class="true"/>
</bean>
like image 102
Rahul Yadav Avatar answered Mar 17 '23 04:03

Rahul Yadav


You can include Bean definition in xml file as below

<bean id="Simple" class="com.example.Simple" scope="prototype" />
like image 45
M S Parmar Avatar answered Mar 17 '23 06:03

M S Parmar