Fehler nach dem Umzug <mvc:annotation-driven/>: keine Erklärung finden für element 'mvc:annotation-driven"
Habe ich eine dispatcher-servlet.xml und ein applicationContext.xml.
Ich habe ein wenig refactoring und zog
<mvc:annotation-driven/>
<context:component-scan base-package="com.xxx"/>
aus dispatcher-servlet.xml zu applicationContext.xml.
Bekomme ich jetzt diese Fehlermeldung:
2012-01-26 10:34:36.434:WARN::Nested in org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.
Meine applicationContext.xml sieht wie folgt aus:
<?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:p="http://www.springframework.org/schema/p"
xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.2.xsd"
xmlns:context="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
>
<mvc:annotation-driven/>
<context:component-scan base-package="com.xxx"/>
<bean id="templateErrorListener"
class="com.stringtemplate.log.Slf4jStringTemplateErrorListener"/>
<bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:config-location="/WEB-INF/ehcache.xml"/>
<ehcache:annotation-driven cache-manager="ehCacheManager"/>
</beans>
und meine dispatcher-servlet.xml sieht aus wie:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="order" value="1"/>
<property name="mediaTypes">
<map>
<entry key="json" value="application/json"/>
</map>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"/>
</list>
</property>
<property name="ignoreAcceptHeader" value="true"/>
</bean>
<bean class="com.stringtemplate.StringTemplateViewResolver">
<property name="templateErrorListener" ref="templateErrorListener"/>
<property name="templateRoot" value="/WEB-INF/templates/"/>
<property name="order" value="2"/>
</bean>
<!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="3"/>
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="formHttpMessageConverter"/>
<ref bean="stringHttpMessageConverter"/>
</list>
</property>
</bean>
<bean id="formHttpMessageConverter "
class="org.springframework.http.converter.FormHttpMessageConverter "/>
<bean id="stringHttpMessageConverter "
class="org.springframework.http.converter.StringHttpMessageConverter "/>
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate"/>
<bean id="applicationProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:${systemTargetEnv}/app.properties</value>
<value>classpath:/build.properties</value>
</list>
</property>
<property name="systemPropertiesModeName">
<value>SYSTEM_PROPERTIES_MODE_OVERRIDE</value>
</property>
</bean>
</beans>
Du musst angemeldet sein, um einen Kommentar abzugeben.
Sie nicht wollen, zu tun.
<mvc:annotation-driven/>
ist es zu ermöglichen, annotation-Stil, MVC-Controllern, und jene Verantwortlichen müssen Ihren Wohnsitz indispatcher-servlet.xml
. Setzen<mvc:annotation-driven/>
imapplicationContext.xml
sinnlos ist, wird es keinen sinnvollen Effekt.Ich sollte wohl die Frage beantworten, obwohl, amnd die Antwort ist, dass, während Sie haben erklärt, die
mvc
namespace, Sie wollte nicht sagen, Frühjahr, wo man das schema für es. Hinzufügenden
schemaLocation
Attribut inapplicationContext.xml