2012-04-29 5 views
21

मुझे अपनी "टीएक्स: एनोटेशन-संचालित" लाइन पर उपरोक्त त्रुटि मिल रही है, लेकिन मैंने बीन्स फ़ाइल के शीर्ष पर नामस्थान घोषित कर दिया है, निम्नलिखित XML इस त्रुटि का कारण क्यों है?तत्व "टीएक्स: एनोटेशन-संचालित" के लिए वसंत "उपसर्ग" टीएक्स "बाध्य नहीं है।"

<?xml version="1.0" encoding="UTF-8"?> 
<beans:beans xmlns="http://www.springframework.org/schema/mvc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/tx 
     http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> 

    <!-- DispatcherServlet Context: defines this servlet's request-processing 
     infrastructure --> 

    <!-- Enables the Spring MVC @Controller programming model --> 
    <tx:annotation-driven transaction-manager="hibernateTransactionManager"/> 

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving 
     up static resources in the ${webappRoot}/resources directory --> 
    <resources mapping="/resources/**" location="/resources/" /> 


    <!-- Resolves views selected for rendering by @Controllers to .jsp resources 
     in the /WEB-INF/views directory --> 
    <beans:bean 
     class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <beans:property name="prefix" value="/WEB-INF/views/" /> 
     <beans:property name="suffix" value=".jsp" /> 
    </beans:bean> 

    <beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" 
     destroy-method="close"> 
     <beans:property name="driverClassName" value="com.mysql.jdbc.Driver" /> 
     <beans:property name="url" value="jdbc:mysql://localhost/assessme" /> 
     <beans:property name="username" value="assessme" /> 
     <beans:property name="password" value="assessme" /> 
    </beans:bean> 

    <beans:bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 
    <beans:property name="annotatedClasses"> 
     <beans:list> 
      <beans:value>org.assessme.com.entity.User</beans:value> 
     </beans:list> 
    </beans:property> 
     <beans:property name="dataSource" ref="dataSource" /> 
     <beans:property name="packagesToScan" value="org.assessme.com.controller.entity" /> 
     <beans:property name="hibernateProperties"> 
      <beans:props> 
       <beans:prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</beans:prop> 
       <beans:prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</beans:prop> 
       <beans:prop key="hibernate.show_sql">true</beans:prop> 
       <beans:prop key="hibernate.hbm2ddl.auto">update</beans:prop> 
      </beans:props> 
     </beans:property> 
    </beans:bean> 

    <context:component-scan base-package="org.assessme.com." /> 

    <beans:bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> 
     <beans:property name="mediaTypes"> 
      <beans:map> 
       <beans:entry key="html" value="text/html" /> 
       <beans:entry key="json" value="application/json" /> 
      </beans:map> 
     </beans:property> 
     <beans:property name="defaultViews"> 
      <beans:list> 
       <beans:bean 
        class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"> 
        <beans:property name="prefixJson" value="true" /> 
       </beans:bean> 
      </beans:list> 
     </beans:property> 
    </beans:bean> 
<beans:bean id="hibernateTransactionManager" 
     class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 
     <beans:property name="sessionFactory" ref="sessionFactory" /> 
    </beans:bean> 

</beans:beans> 

उत्तर

63

बस अपने अन्य xmlns की तरह: definations, आप xmlns के लिए एक की जरूरत है: TX

xmlns:tx="http://www.springframework.org/schema/tx" 
+0

भयानक - धन्यवाद, इस थोड़ा विचित्र है, लेकिन यह मीटर में से कोई भी जोड़ने, अब के बाद मेरे नियंत्रकों में वाई एमवीसी @requestmapping काम और मेरा आवेदन सिर्फ 404 है क्योंकि dispatcherservlet कहते हैं कि यह कुछ भी नक्शा नहीं कर सकता है। आपके पास कोई विचार है? – david99world

+0

मुझे वसंत वेबफ्रेमवर्क अच्छी तरह से नहीं पता है, लेकिन शायद इसलिए कि मुझे लगता है कि xmlns नहीं है: टीएक्स आपकी समस्याओं का स्रोत है।
क्या आप अपने युद्ध में वसंत लेनदेन + एओपी पुस्तकालयों को शामिल करना भूल गए हैं। –

19

आप अधिक जानकारी के लिए here लग सकता है:

सभी को विन्यस्त साथ tx टैग सौदा वसंत के लेनदेन के लिए व्यापक समर्थन में उन बीन्स का। ये टैग अध्याय 9, लेनदेन प्रबंधन नामक अध्याय में शामिल हैं।

...

पूर्णता के हित में, tx स्कीमा में टैग का उपयोग करने के लिए, आप अपने स्प्रिंग एक्सएमएल विन्यास फाइल के शीर्ष पर निम्न प्रस्तावना की जरूरत; निम्नलिखित स्निपेट में उभरा पाठ सही स्कीमा का संदर्भ देता है ताकि टीएक्स नेमस्पेस में टैग आपके लिए उपलब्ध हों।

<?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:tx="http://www.springframework.org/schema/tx" 
     xsi:schemaLocation=" 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd 
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> 

    <!-- <bean> definitions goes here --> 

</beans> 
0

आप अपनी परियोजना के लिए एनोटेशन tx परिचय चाहिए आप उन्हें स्थापित करना होगा न xmlns उपयोग करें, यह correcty काम नहीं करता है, मुझे लगता है कि आप अपने अच्छे व्यवहार टिप्पणी के साथ विकसित करने और इस का उपयोग ,

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx.xsd

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