我正在尝试运行我工作中一位前雇员留下的系统,但我在执行时遇到了问题。
如果 XSD 通过远程访问运行:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="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.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
它给出了一个未找到的异常:
Failed to read schema document 'http://www.springframework.org/schema/context/spring-context-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
如果 XSD 通过本地访问运行:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
classpath:org/springframework/transaction/config/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
classpath:org/springframework/context/config/spring-context-3.0.xsd
http://www.springframework.org/schema/tool
classpath:org/springframework/beans/factory/xml/spring-tool-3.0.xsd">
它给出了这个异常(exception):
C:\Users\claudiomazur>java -jar c:\temp\fin\c.jar
0 [AWT-EventQueue-0] INFO support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@4fa52fdf: startup date [Thu Sep 06
11:22:59 BRT 2012]; root of context hierarchy
45 [AWT-EventQueue-0] INFO xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [context.xml]
Exception in thread "AWT-EventQueue-0" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for
XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [context.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
解决这个问题的想法?
大大的拥抱!!
最佳答案
Spring XDS 是随 Spring jar 一起定义和交付的!例如,spring-context.jar
包含 spring-context-3.0.xsd
。 (参见 spring-context.jar
/META-INF/spring.schema)
因此请检查您的项目中是否有这个 jar。
所以你所说的“远程”并不是真正的远程!而且我从来没有看到你所谓的“本地访问”,所以我会尝试检查为什么“远程”(不是远程)东西适用于所有 xsds 但 spring-context。
如果它是一个桌面程序并且您使用一个包含所有其他分解 jar 的单个 jar,那么您需要注意单个 spring.handlers
和 的内容来自不同 spring-xxx.jar 的 spring.schames
文件组合在(两个)“hunge”文件中。所以最后这个(两个)文件包含所有模式名称和处理程序名称。
关于java - Spring XSD的访问报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12350673/