gpt4 book ai didi

Spring JDO 配置解析错误

转载 作者:行者123 更新时间:2023-12-01 15:24:34 26 4
gpt4 key购买 nike

我有一个 spring 测试用例,注释如下

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

我的 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">

当我运行测试时,我得到
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'.

如果我将 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">

错误是

Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://java.sun.com/xml/ns/jdo/jdoconfig] Offending resource: class path resource [META-INF/jdoconfig.xml]



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

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

最佳答案

您的 jdoconfig.xml 包含不正确的 url。尝试这个:

xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig http://java.sun.com/xml/ns/jdo/jdoconfig_3_0.xsd"

Validating jdoconfig with incorrect url

How to solve validation error on xsi:noNamespaceSchemaLocation in jdoconfig.xml

关于Spring JDO 配置解析错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14514520/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com