की प्रत्येक कॉल के लिए सेम का नया उदाहरण बना रहा है: Connection manager
हर बार ConnectionServer
में से एक वस्तु और DataBean
तो की नई वस्तुओं होना चाहिए, मैं इन सेम बनाया है और वह वसंत एक्सएमएल बाहर कॉन्फ़िगर किया है ।स्प्रिंग: अगले स्थिति प्राप्त विधि
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="dataBena" class="com.test.DataBean" scope="prototype"/>
<bean id="servCon" class="com.test.ServerCon"/>
<!--<bean id="test" class="com.test.Test"/>-->
<context:component-scan base-package="com.test"/>
</beans>
और के लिए DataBean
गुंजाइश prototype
जोड़ा इस के बाद मैं util/घटक वर्ग कहा जाता टेस्ट
@Component
public class Test {
@Autowired
private DataBean bean;
@Autowired
private ServerCon server;
public DataBean getBean() {
return bean.clone();
}
public ServerCon getServer() {
return server;
}
}
लेकिन, getBean() विधि मैं क्लोनिंग कर रहा हूँ बुलाने की हर बार सरल बना लिया है यह बीन, और यह मेरी समस्या है। क्या मैं इसे क्लोन कॉन्फ़िगरेशन से क्लोन विधि के बिना कर सकता हूं? धन्यवाद।
बस अपने क्लासस्पैट में [cglib.jar] (http://repo1.maven.org/maven2/cglib/cglib/2.2.2/cglib-2.2.2.jar) जोड़ें। –
और asm-all-3.3.1.jar भी :), धन्यवाद सब अच्छा काम करता है! –
यदि आप 'डेटाबीन' एक सामान्य है और यदि उसके अंदर '' प्रकार के आधार पर '@ Autowired' है, तो 'सेवा ' है, तो आप इसे कैसे संभालेंगे? –