2017-04-02 52 views
0

我目前在春天工作,我对这个框架非常陌生。我已经添加了所有需要的弹簧罐,并编写了以下spring-dispatcher-servlet.xml文件。spring.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:mvc="http://www.springframework.org/schema/mvc" 
xmlns:tx="http://www.springframework.org/schema/tx" 
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.1.xsd 
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.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.1.xsd"> 

    <context:component-scan base-package="com.quiz_mcq.controller, com.quiz_mcq.service, com.quiz_mcq.dao"/> 
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <property name="prefix" value="/" /> 
     <property name="suffix" value=".jsp" /> 
    </bean> 

</beans> 

我的代码在互联网连接时工作正常,但当我没有连接到互联网时发生故障。并给出以下错误。

第12行来自ServletContext资源的XML文档[/WEB-INF/spring->dispatcher-servlet.xml]无效;嵌套异常是org.xml.sax.SAXParseException; lineNumber:12; columnNumber:109; cvc-complex-type.2.4.c:匹配通配符是严格的,但是对元素'context:component-scan'没有声明。

我在做什么错在这里?
任何人都可以告诉我解决方案什么需要做甚至脱机工程的项目?

+3

[Spring schemaLocation可能在没有互联网连接时失败](http://stackoverflow.com/questions/1729307/spring-schemalocation-fails-when-there-is-no-互联网连接) – developer

回答

0

为XSI模式位置放

XSI:=的schemaLocation “http://www.springframework.org/schema/beans 类路径:组织/ springframework的/豆/工厂/ XML /弹簧豆-3.0.xsd http://www.springframework.org/schema/context 类路径:组织/ springframework的/豆/factory/xml/spring-context-3.0.xsd”

在您的案件代码

需要每次

我提供的模式位置应该工作,因为XSD是包检查springframework.com d在弹簧罐里面

+0

我在模式位置添加了你的代码,但它仍然给我同样的错误 – Vipul