尝试在无法访问Internet的计算机上启动Spring Web应用程序时出现此异常。
.... more duplicate definition errors
2015-11-11 00:58:19,284 INFO [stdout] (MSC service thread 1-1) http://www.springframework.org/schema/beans/spring-beans-3.2.xsd<Line 1048, Column 39>: XML-24509: (Error) Duplicated definition for: 'propertyType'
2015-11-11 00:58:19,284 INFO [stdout] (MSC service thread 1-1) http://www.springframework.org/schema/beans/spring-beans-3.2.xsd<Line 1092, Column 41>: XML-24509: (Error) Duplicated definition for: 'collectionType'
2015-11-11 00:58:19,284 INFO [stdout] (MSC service thread 1-1) http://www.springframework.org/schema/beans/spring-beans-3.2.xsd<Line 1104, Column 40>: XML-24509: (Error) Duplicated definition for: 'listOrSetType'
2015-11-11 00:58:19,284 INFO [stdout] (MSC service thread 1-1) http://www.springframework.org/schema/beans/spring-beans-3.2.xsd<Line 1113, Column 34>: XML-24509: (Error) Duplicated definition for: 'mapType'
2015-11-11 00:58:19,284 INFO [stdout] (MSC service thread 1-1) http://www.springframework.org/schema/beans/spring-beans-3.2.xsd<Line 1135, Column 36>: XML-24509: (Error) Duplicated definition for: 'entryType'
2015-11-11 00:58:19,284 INFO [stdout] (MSC service thread 1-1) http://www.springframework.org/schema/beans/spring-beans-3.2.xsd<Line 1182, Column 36>: XML-24509: (Error) Duplicated definition for: 'propsType'
2015-11-11 00:58:19,285 INFO [stdout] (MSC service thread 1-1) http://www.springframework.org/schema/beans/spring-beans-3.2.xsd<Line 1195, Column 45>: XML-24509: (Error) Duplicated definition for: 'defaultable-boolean'
2015-11-11 00:58:19,286 DEBUG [org.springframework.beans.factory.xml.PluggableSchemaResolver] (MSC service thread 1-1) Found XML schema [http://www.springframework.org/schema/context/spring-context-3.2.xsd] in classpath: org/springframework/context/config/spring-context-3.2.xsd
2015-11-11 00:58:19,288 DEBUG [org.springframework.beans.factory.xml.PluggableSchemaResolver] (MSC service thread 1-1) Found XML schema [http://www.springframework.org/schema/beans/spring-beans-3.2.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-3.2.xsd
2015-11-11 00:58:19,289 DEBUG [org.springframework.beans.factory.xml.PluggableSchemaResolver] (MSC service thread 1-1) Found XML schema [http://www.springframework.org/schema/tool/spring-tool-3.2.xsd] in classpath: org/springframework/beans/factory/xml/spring-tool-3.2.xsd
2015-11-11 00:58:19,291 DEBUG [org.springframework.beans.factory.xml.PluggableSchemaResolver] (MSC service thread 1-1) Found XML schema [http://www.springframework.org/schema/aop/spring-aop-3.2.xsd] in classpath: org/springframework/aop/config/spring-aop-3.2.xsd
2015-11-11 00:58:19,293 DEBUG [org.springframework.beans.factory.xml.PluggableSchemaResolver] (MSC service thread 1-1) Found XML schema [http://www.springframework.org/schema/beans/spring-beans-3.2.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-3.2.xsd
2015-11-11 00:58:19,293 DEBUG [org.springframework.beans.factory.xml.PluggableSchemaResolver] (MSC service thread 1-1) Found XML schema [http://www.springframework.org/schema/tool/spring-tool-3.2.xsd] in classpath: org/springframework/beans/factory/xml/spring-tool-3.2.xsd
2015-11-11 00:42:03,990 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-2) Context initialization failed: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from ServletContext resource [/WEB-INF/service-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 113; <Line 10, Column 113>: XML-24500: (Error) Can not build schema 'http://www.springframework.org/schema/beans' located at 'http://www.springframework.org/schema/beans/spring-beans-3.2.xsd'
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
应用程序上下文如下:
<?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:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd">
pom中的所有Spring依赖项都是版本3.2.0.RELEASE。我已经检查过所有XSD在指定版本的类路径上是否可用,spring.handlers和spring.schemas看起来是正确的并且指向右/现有的处理程序和模式。
还有什么问题?
编辑:同一个容器中还有其他应用程序。这可能与这个问题有关吗?
service-servlet.xml:
<?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:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd">
<!-- <import resource="applicationContext.xml" /> -->
<context:component-scan base-package="com.my.package" />
<mvc:annotation-driven
content-negotiation-manager="contentNegotiationManager" />
<bean id="contentNegotiationManager"
class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="favorPathExtension" value="false" />
</bean>
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jsonConverter" />
</list>
</property>
</bean>
<bean id="jsonConverter"
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes" value="application/json"></property>
</bean>