Spring JDO配置解析错误

kay*_*ubi 3 validation spring config jdo

我有一个注释如下的弹簧测试用例

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:conf/allocadia-base.xml", "classpath:META-INF/jdoconfig.xml"})
Run Code Online (Sandbox Code Playgroud)

我的jdoconfig是

<?xml version="1.0" encoding="utf-8"?>
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
Run Code Online (Sandbox Code Playgroud)

当我运行测试时,我得到了

java.lang.IllegalStateException: Failed to load ApplicationContext 
.  
. 
.  
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from class path resource [META-INF/jdoconfig.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'jdoconfig'.
Run Code Online (Sandbox Code Playgroud)

如果我改变了jdoconfig

<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig http://java.sun.com/xml/ns/jdo/jdoconfig_2_3.xsd">
Run Code Online (Sandbox Code Playgroud)

错误是

引起:org.springframework.beans.factory.parsing.BeanDefinitionParsingException:配置问题:无法找到XML架构命名空间的Spring NamespaceHandler [http://java.sun.com/xml/ns/jdo/jdoconfig]违规资源:class路径资源[META-INF/jdoconfig.xml]

我使用最新的spring 3.2和JDO 2.3-e

我将它部署到tomcat时应用程序工作正常我只是在尝试运行测试时遇到此错误

bur*_*vyg 11

您的jdoconfig.xml包含不正确的网址.试试这个:

xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig http://java.sun.com/xml/ns/jdo/jdoconfig_3_0.xsd"
Run Code Online (Sandbox Code Playgroud)

使用不正确的url验证jdoconfig

如何解决jdoconfig.xml中xsi:noNamespaceSchemaLocation的验证错误