gpt4 book ai didi

java - 无法找到 XML 模式命名空间的 Spring NamespaceHandler [http ://jboss. org/xml/ns/javax/validation/configuration]

转载 作者:行者123 更新时间:2023-11-30 11:57:59 25 4
gpt4 key购买 nike

我正在使用 spring 3,hibernate validator 4。我的单元测试运行良好。但是我得到这个(见下文)用于我的功能测试,我是否遗漏了一些依赖项?

我为 hibernate validator 添加的依赖项:

  1. validation-api-1.0.0.GA.jar
  2. hibernate-validator-4.0.2.GA.jar

这是我的 validation.xml 的内容:

<?xml version="1.0" encoding="UTF-8"?>

<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration
http://jboss.org/xml/ns/javax/validation/configuration/validation-configuration-1.0.xsd">

<default-provider>org.hibernate.validator.HibernateValidator</default-provider>
<message-interpolator>org.hibernate.validator.engine.ResourceBundleMessageInterpolator</message-interpolator>
<traversable-resolver>org.hibernate.validator.engine.resolver.DefaultTraversableResolver</traversable-resolver>
<constraint-validator-factory>org.hibernate.validator.engine.ConstraintValidatorFactoryImpl</constraint-validator-factory>
<!-- <configuration:constraint-mapping>constraints-user.xml</configuration:constraint-mapping> -->

</validation-config>

错误:

Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://jboss.org/xml/ns/javax/validation/configuration]
Offending resource: class path resource [hibernate/validation.xml]

at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:284)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1332)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1325)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:142)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:187)
... 57 more

我四处搜索,但没有找到解决方案 =(。有什么想法吗?谢谢~!

最佳答案

validation.xml 不是 Spring 配置文件,你不应该尝试用 Spring 加载它。

关于java - 无法找到 XML 模式命名空间的 Spring NamespaceHandler [http ://jboss. org/xml/ns/javax/validation/configuration],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3429242/

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