2017-04-26 1 views
0

Ich bin neu bei springMVC. Mit springMVC 4.2.4, Tomacat 9.0, Maven 4.0, Java 1.8, Eclipse IDE und wenn ich versuche, eine Bean in eine Bean zu schreiben, wird ein Fehler angezeigt. Das Folgende ist die Konfigurations-XML-Datei.Ich erhalte den folgenden Fehler beim Erstellen von Bean in Xml ** CVC-Komplex-Typ.2.4.a: Ungültiger Inhalt wurde beginnend mit Element 'Bean' gefunden **

<?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" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:p="http://www.springframework.org/schema/p" 
    xsi:schemaLocation="http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd 
    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-3.2.xsd"> 

<mvc:annotation-driven /> 

<mvc:resources location="pdfs" mapping="/pdfs/**" /> 


    <context:component-scan base-package="com.springmvc.controller" /> 

<mvc:interceptors> 
    <bean 
    class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" 
     p:paramName="language" /> 
</mvc:interceptors> 

<bean 

class= 
    "org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> 
    <property name="order" value="1" /> 
    <property name="ContentNegotiationManager" /> 
    **<bean** 
    class="org.springframework.web.accept.ContentNegotiationManager"> 
     <constructor-arg> 
      <bean 

    class="org.springframework. 
    web.accept.PathExtensionContentNegotiationStrategy"> 
       <constructor-arg> 
        <map> 
         <entry key="json" value="application/json" /> 
         <entry key="xml" value="application/xml" /> 
        </map> 
       </constructor-arg> 
      </bean> 
     </constructor-arg> 
    </bean> 
    <property name="defaultViews"> 
     <list> 
      <bean 

    class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" 
    /> 
      <bean 
    class="org.springframework.wweb.servlet.view.xml.MarshallingView"> 
       <constructor-arg> 
        <bean 
    class="org.springframework.oxm.xstream.XStreamMarshaller"> 
         <property name="autodetectAnnotations" value="true" 
    /> 
        </bean> 
       </constructor-arg> 
      </bean> 
     </list> 
    </property> 
</bean> 
</beans> 
+0

können Sie bitte Sie komplette Fehler teilen sehen – ScanQR

Antwort

0

Der Fehler ist hier:

<?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" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:p="http://www.springframework.org/schema/p" 
    xsi:schemaLocation="http://www.springframework.org/schema/mvc 

Sie nicht die bean Namespace enthalten sind. Um das zu lösen, fügen Sie es bitte hinzu. Hier ein Beispiel (von meinem Projekt).

<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" <!-- THIS ONE--> 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:mvc="http://www.springframework.org/schema/mvc" 
xmlns:aop="http://www.springframework.org/schema/aop" 
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd 
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd 
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> 

Dann eine neue Bean instanziiert:

<beans:bean id="...." class="......"/> 
Verwandte Themen