को मेरे वसंत आवेदन में कुछ समस्या हो रही है।स्प्रिंग सिंगलटन को दो बार
मेरे पास बहुत ही साधारण वसंत सेम हैं, इन्हें विभिन्न अन्य वसंत बीन्स में इंजेक्शन दिया जाता है। मुझे डिबगिंग मिलने पर, उन्हें दो बार बुलाया जा रहा है, कन्स्ट्रक्टर & @ पोस्ट कॉन्स्ट्रक्ट दोनों को दो बार कहा जाता है।
मेरे आवेदन में कोई फ्रंट एंड तकनीक नहीं है। इसके बैकएंड कार्य से संबंधित है।
स्प्रिंग विन्यास
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:lang="http://www.springframework.org/schema/lang" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd">
<context:component-scan base-package="com.green.integration" />
<!-- ######################################################## -->
<!-- EXPOSING SPRING BEAN VIA HTTPINVOKER SPRING REMOTING -->
<!-- ######################################################## -->
<bean name="/switch"
class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service" ref="SwitchController" />
<property name="serviceInterface"
value="com.green.ISwitchController" />
</bean>
<!-- Load in application properties reference -->
<bean id="applicationProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:application.properties" />
</bean>
<bean id="mongo" class="com.mongodb.Mongo">
<constructor-arg value="${mongo.server}" />
<constructor-arg value="${mongo.port}" />
</bean>
<bean id="morphia" class="com.google.code.morphia.Morphia">
</bean>
</beans>
स्प्रिंग बीन कक्षा
@Repository
public class TransactionDAO extends BasicDAO<Transaction, ObjectId> {
private Datastore datastore;
@Autowired
public TransactionDAO(Mongo mongo, Morphia morphia) {
super(mongo, morphia, "itransact");
morphia.map(Transaction.class);
// TO USE MONGO WITHOUT SECURITY
this.datastore = morphia.createDatastore(mongo, "itransact");
logger.debug("***** CONNECTED TO MONGODB SUCCESSFULLY *****");
this.datastore.ensureIndexes();
// this.datastore.ensureCaps();
}
}
निर्माता "TransactionDAO" दो बार बुलाया जा रहा है।
मैं
Throwable t = new Throwable();
System.out.println(t.getStackTrace()[1].toString());
द्वारा कॉल स्टैक ट्रेस देखने के लिए कोशिश की और हर बार यह निम्नलिखित
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
क्या आप पूरी तरह से सुनिश्चित हैं कि '@ PostConstruct' को दो बार भी बुलाया जाता है? दो बार बुलाया जाने वाला कन्स्ट्रक्टर आसानी से समझाया जा सकता है, लेकिन '@ पोस्ट कॉन्स्ट्रक्ट' नहीं। –
क्या आपके पास एक प्रेषक सर्वलेट कॉन्फ़िगरेशन है? –
हो सकता है कि आपके पास के माध्यम से किसी अन्य संदर्भ की xml कॉन्फ़िगरेशन फ़ाइल से आयात किया गया आपका आवेदन संदर्भ xml हो? –