春天,每当我写作 在我的dispatcher-servlet.xml中,我收到此错误: -
Blockquote SEVERE:上下文初始化失败 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自ServletContext资源[/WEB-INF/dispatcher-servlet.xml]的XML文档中的第17行无效;嵌套异常是org.xml.sax.SAXParseException; lineNumber:17; columnNumber:65; cvc-complex-type.2.4.c:匹配的通配符是strict,但是没有为元素'mvc:resources'找到声明。 在org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396) 在org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) 在org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) 在org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) 在org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) 在org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) 在org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) 在org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) 在org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465) 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395) 在org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272) 在org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196) 在org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584) 在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) 在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1572) 在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1562) 在java.util.concurrent.FutureTask.run(FutureTask.java:262) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615) 在java.lang.Thread.run(Thread.java:745) 引起:org.xml.sax.SAXParseException; lineNumber:17; columnNumber:65; cvc-complex-type.2.4.c:匹配的通配符是strict,但是没有为元素'mvc:resources'找到声明。 at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) 在org.apache.xerces.util.ErrorHandlerWrapper.error(未知来源) 在org.apache.xerces.impl.XMLErrorReporter.reportError(未知来源) 在org.apache.xerces.impl.XMLErrorReporter.reportError(未知来源) at org.apache.xerces.impl.xs.XMLSchemaValidator $ XSIErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(未知来源) at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(未知来源) at org.apache.xerces.impl.xs.XMLSchemaValidator.emptyElement(未知来源) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl $ FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) 在org.apache.xerces.parsers.XML11Configuration.parse(未知来源) 在org.apache.xerces.parsers.XML11Configuration.parse(未知来源) 在org.apache.xerces.parsers.XMLParser.parse(未知来源) 在org.apache.xerces.parsers.DOMParser.parse(未知来源) 在org.apache.xerces.jaxp.DocumentBuilderImpl.parse(未知来源) 在org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75) 在org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388) ......还有22个
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd ">
<mvc:resources location="/resources/**" mapping="/resources/"/>
<mvc:annotation-driven/>
<context:property-placeholder location="classpath:jdbc.properties" />
<context:component-scan base-package="id.jexpress" />
<tx:annotation-driven transaction-manager="hibernateTransactionManager" />
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${database.driver}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.user}" />
<property name="password" value="${database.password}" />
</bean>
答案 0 :(得分:0)
您似乎错过了类路径中的架构 - XSD位于the subproject并捆绑到spring-webmvc jar中。
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
对我来说很好用