我有一个 spring 配置来使用 jaxws 创建带有 cxf 的客户端。当我使用以下代码从主类运行测试用例时:
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:spring/client-context.xml");
return (VisitService) ctx.getBean("client");
我得到这个异常
org.xml.sax.SAXParseException; lineNumber: 21; columnNumber: 71; schema_reference.4: Failed to read schema document 'http://cxf.apache.org/schema/jaxws.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .
我理解这个异常,并在 cxf http://cxf.apache.org/docs/embedding-cxf-inside-spring.html 的文档中找到了这个异常
Include <import resource="classpath:META-INF/cxf/cxf.xml" />
当我包含文档中描述的 context.xml 时,我得到了同样的错误。 Spring 在加载此 xml 之前验证其架构。包装应用程序上下文可能会解决我的问题,但这似乎是一个较差的解决方案。我知道 xsd 应该位于我的类路径上,而且它位于 cxf-rt-frontend-jaxws jar 中。
最佳答案
cxf 文档有时使用 http://cxf.apache.org/schema/jaxws.xsd有时使用 http://cxf.apache.org/schemas/jaxws.xsd CXF3需要http://cxf.apache.org/schema s/jaxws.xsd
关于java - cxf spring 配置无法加载,缺少 xsd,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24563583/