从dozer-mapping.xml </mappings>读取<mappings>时的SaxParser Eception

时间:2013-09-18 11:28:01

标签: java dozer

我正在尝试在我的项目中实现DOZER。我得到了SAX例外。 PFB,细节

  

org.dozer.MappingException:org.xml.sax.SAXException:解析错误   行:4   URI:null   消息:cvc-elt.1:找不到元素'映射'的声明。       在org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:82)       at org.dozer.loader.xml.MappingStreamReader.read(MappingStreamReader.java:55)       在org.dozer.loader.xml.MappingFileReader.read(MappingFileReader.java:58)       在org.dozer.DozerBeanMapper.loadFromFiles(DozerBeanMapper.java:227)       在org.dozer.DozerBeanMapper.loadCustomMappings(DozerBeanMapper.java:209)       在org.dozer.DozerBeanMapper.initMappings(DozerBeanMapper.java:315)       在org.dozer.DozerBeanMapper.getMappingProcessor(DozerBeanMapper.java:192)       在org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:120)

我的dozer-mapping.xml

<?xml version="1.0" encoding="UTF-8"?>
<mappings xmlns:ns="http://dozer.sourceforge.net"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://dozer.sourceforge.net 
           http://dozer.sourceforge.net/schema/beanmapping.xsd">
  <mapping>
<class-a>org.esb.ClassA</class-a>
<class-b>org.esb.ClassB</class-b>
<field>
    <a>status</a>
    <b>statusCode</b>
</field>
 </mapping>
</mappings>

我的java代码:

destinationObj= dozerBeanMapper.map(sourceObj, DestinationClass.class);

使用的罐子:

Dozer 5.4.0.jar,commons-beanutils-1.8.3.jar,commons-lang-2.6.jar,jcl-over-slf4j-1.6.6.jar,log4j-1.2.15.jar,slf4j- api-1.6.6.jar,slf4j-log4j12-1.6.6.jar

1 个答案:

答案 0 :(得分:1)

由于此xmlns:ns="http://dozer.sourceforge.net",架构仅适用于ns命名空间中的xml。

相反,您应该像this dozer-example中一样写xmlns="http://dozer.sourceforge.net"