2013-06-25 5 views
5

मैं जेडीबीसी का उपयोग कर डेटाबेस से पूछताछ करने के लिए Mule 3 का उपयोग कर रहा हूं, और मैं एक .properties फ़ाइल से इनपुट के आधार पर क्वेरी को संशोधित करना चाहता हूं। मैं अपने एक्सएमएल में यह है ...म्यूले 3 - .properties फ़ाइल से लोड हो रहा है

<context:property-placeholder location="C:\path\to\file\settings.properties" /> 

निम्नलिखित अपवाद हो रही है ...

Exception in thread "main" org.mule.module.launcher.DeploymentInitException: SAXParseException: The prefix "context" for element "context:property-placeholder" is not bound. 

मैं कुछ विशेष .XSD फ़ाइल को शामिल करने की जरूरत है?

उत्तर

7

अपने खच्चर config खच्चर टैग एलिमेंट को xmlns नामस्थान उपसर्ग और स्कीमा स्थान जोड़ें।

उपसर्ग:

xmlns:context="http://www.springframework.org/schema/context" 

SchemaLocation:

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 

यह नीचे के रूप में की तरह दिखना चाहिए।

उदाहरण के लिए:

<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:spring="http://www.springframework.org/schema/beans"  
    xmlns:http="http://www.mulesoft.org/schema/mule/http" 
    xmlns:context="http://www.springframework.org/schema/context" 

    xsi:schemaLocation=" 
     http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.3/mule.xsd 
     http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.3/mule-http.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd  
     "> 


<context:property-placeholder location="C:/path/to/file/settings.properties" /> 


    ........... Other stuff 



</mule> 
+0

धन्यवाद। ऐसा लगता है कि नामस्थान समस्या ठीक हो गई है लेकिन फ़ाइल स्पष्ट रूप से मौजूद होने पर मुझे FileNotFound अपवाद मिल रहा है। क्या आपने पहले इस मुद्दे का अनुभव किया है? – Narabhut

+0

इस मुद्दे के बारे में एक नया प्रश्न बनाया गया है, यहां लिंक है http://stackoverflow.com/questions/17326783/filenotfound-exception-while-loading-from-a-properties-file-in-mule कृपया देखें कि क्या आप हल कर सकते हैं – Narabhut

+0

आपके प्रश्न के लिए एक उत्तर पोस्ट किया गया है। कृपया इसे आजमाएं। इसे हल करना चाहिए। ताज़ा करने के लिए – user1760178

0

xsi में निम्नलिखित XSD का उपयोग करें: schemaLocation -

http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-current.xsd

+0

मुझे एक ही अपवाद है। मुझे यह जोड़ना चाहिए कि मैं प्लेसहोल्डर को खंभे टैग के अंदर रख रहा हूं, यानी '<संदर्भ: संपत्ति-प्लेसहोल्डर स्थान =" सी: \ path \ to \ file \ settings.properties "/> Narabhut

0

अन्य उत्तर नाम स्थान मुद्दा कवर, लेकिन मैं मैंने पाया कि इस संदर्भ जोड़ देंगे: ": सेम वसंत" टैग संपत्ति-प्लेसहोल्डर टैग के बीच होने की जरूरत।

<mule xmlns="http://www.mulesoft.org/schema/mule/core" version="EE-3.4.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
     xmlns:spring="http://www.springframework.org/schema/beans" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xsi:schemaLocation=" 
      http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

    <spring:beans> 
     <context:property-placeholder location="C:/path/to/file/settings.properties" /> 
     <spring:bean name="myConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> 
      <spring:property name="brokerURL" value="${jmsBrokerURL}" /> 
     </spring:bean> 
    </spring:beans> 

    <flow name="MyFlow" doc:name="MyFlow"> 
     <!-- Flow configuration here. --> 
    </flow> 

</mule> 

पढ़ने गुण (और एक मैं पसंद करते हैं) की वैकल्पिक विधि वसंत उपयोग करने के लिए है "util: गुण" गुण पढ़ने के लिए टैग यहाँ एक उदाहरण है कि मानती है कि गुण फ़ाइल एक संपत्ति "jmsBrokerURL" नाम सेट है एक गुण बीन में जिसे आप तब स्प्रिंग ईएल का उपयोग करने के लिए संदर्भित करते हैं। इस मामले में देखें कि आप ऑब्जेक्ट और इसके चर के संदर्भ में "$ {}" के बजाय स्प्रिंग ईएल "# {}" नोटेशन का उपयोग करते हैं। यहाँ ऊपर के उदाहरण है कि तकनीक के लिए संशोधित किया गया है:

<mule xmlns="http://www.mulesoft.org/schema/mule/core" version="EE-3.4.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
     xmlns:spring="http://www.springframework.org/schema/beans" 
     xmlns:util="http://www.springframework.org/schema/util" 
     xsi:schemaLocation=" 
      http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
      http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd"> 

    <spring:beans> 
     <util:properties id="myConfig" location="C:/path/to/file/settings.properties" /> 
     <spring:bean name="myConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> 
      <spring:property name="brokerURL" value="#{myConfig.jmsBrokerURL}" /> <!-- Note the pound (hash) symbol. --> 
     </spring:bean> 
    </spring:beans> 

    <flow name="MyFlow" doc:name="MyFlow"> 
     <!-- Flow configuration here. --> 
    </flow> 

</mule> 

मैं यह बाद दृष्टिकोण जिसका मुख्य कारण मैं कई गुण फ़ाइलों के साथ सौदा कर सकते हैं और अधिक आसानी से शामिल आवेदन संदर्भ फ़ाइलें। संदर्भ: संपत्ति-प्लेसहोल्डर टैग कई संपत्ति फ़ाइलों से निपटने के दौरान या किसी अन्य के भीतर एक अनुप्रयोग संदर्भ फ़ाइल सहित जब समस्याग्रस्त हो सकता है।

0

बस डाल गुण संसाधन फ़ोल्डर और

उपयोग इस के तहत दायर "classpath: settings.properties" संपत्ति-प्लेसहोल्डर में और यह काम करेगा ...

4

मैं एक ही मुद्दों था और यह तय । यहाँ मैंने क्या किया।

  1. src/मुख्य/संसाधनों के तहत
  2. < संदर्भ सभी .properties रखा: संपत्ति-प्लेसहोल्डर स्थान = "file.dev.properties, file.stage.properties" />
  3. सभी फाइलों को ध्यान में रखते हुए कक्षा में एक चुनौती थी। तो गोटो आपका प्रोजेक्ट फ़ोल्डर, ओपन।टेक्स्ट पैड में क्लासपाथ फ़ाइल और नीचे दी गई रेखा

    < classpathentry 
        including="file.dev.properties|file.prod.properties|file.stage.properties" 
        kind="src" path="src/main/resources"/ > 
    
  4. सहेजें, रीफ्रेश करें और यह काम करता है।
+0

+1। –

संबंधित मुद्दे