当前位置: 首页 > news >正文

苏州网站设计电话北京十大教育培训机构排名

苏州网站设计电话,北京十大教育培训机构排名,媒体软文推广平台,如何制造一个网页很多老系统,特别是C的系统,可能数据结构采用的xml。xml对java来说没有什么,但是C来说,可能还有个顺序问题,毕竟c没有那么多通用类库。 2 xstream 先说依赖,我本来不想升级,但是有个问题卡者就给…

很多老系统,特别是C++的系统,可能数据结构采用的xml。xml对java来说没有什么,但是C++来说,可能还有个顺序问题,毕竟c++没有那么多通用类库。
2 xstream
先说依赖,我本来不想升级,但是有个问题卡者就给升了,虽然升了并没有解决我的问题。

     <!-- xstream 升级到1.4.18后 依赖的jar --><dependency><groupId>com.thoughtworks.xstream</groupId><artifactId>xstream</artifactId><version>1.4.20</version></dependency><dependency><groupId>xmlpull</groupId><artifactId>xmlpull</artifactId><version>1.1.3.4d_b4_min</version></dependency><dependency><groupId>xpp3</groupId><artifactId>xpp3_min</artifactId><version>1.1.4c</version></dependency>

2.1 双下划线问题
看下面注释

    public static String toXml(Object obj) {
//        XStream xstream = new XStream(new DomDriver(encoding));XStream xstream = new XStream(new Xpp3Driver(new NoNameCoder())); // 解决xml双下划线的问题//            XStream xstream=new XStream(new DomDriver()); //直接用jaxp dom来解释//            XStream xstream=new XStream(new DomDriver("utf-8")); //指定编码解析器,直接用jaxp dom来解释//如果没有这句,xml中的根元素会是<包.类名>;或者说:注解根本就没生效,所以的元素名就是类的属性xstream.processAnnotations(obj.getClass()); //通过注解方式的,一定要有这句话return xstream.toXML(obj);}

2.2 复杂对象转换的问题
一般的复杂结构还不会有问题,但是老式的默认却不行,很奇怪。

com.thoughtworks.xstream.converters.ConversionException: 
---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : COMMON_FPKJ_XMXX
class               : com.whty.einv.sks.model.params.req.body.ReqInvoiceIssueBody026Bean
required-type       : com.whty.einv.sks.model.params.req.body.ReqInvoiceIssueBody026Bean
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
path                : /business/REQUEST_COMMON_FPKJ/COMMON_FPKJ_XMXXS
line number         : 32
class[1]            : com.whty.einv.sks.model.params.req.business.ReqInvoiceIssue026Bean
required-type[1]    : com.whty.einv.sks.model.params.req.business.ReqInvoiceIssue026Bean
version             : 1.4.20
-------------------------------at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:81)at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:499)at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:425)at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:72)at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:68)at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:52)at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:136)at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1464)at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1441)at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1321)at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1312)at com.whty.einv.sks.model.util.XmlUtil.toBean(XmlUtil.java:53)at com.whty.einv.sks.model.test.TestJavaToXml.toBean(TestJavaToXml.java:108)at com.whty.einv.sks.model.test.TestJavaToXml.test10_026(TestJavaToXml.java:86)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)at org.junit.runners.ParentRunner.run(ParentRunner.java:363)at org.junit.runner.JUnitCore.run(JUnitCore.java:137)at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: COMMON_FPKJ_XMXXat com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:81)at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:79)at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:74)at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)at com.thoughtworks.xstream.mapper.SecurityMapper.realClass(SecurityMapper.java:71)at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:47)at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:420)at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:277)at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:74)... 40 moreProcess finished with exit code -1

.1 jibx实现
先看依赖,使用这个技术比较麻烦一点,就是再打包的时候要执行mvn jibx:bind

  <dependency><groupId>org.jibx</groupId><artifactId>jibx-run</artifactId><version>1.3.1</version></dependency><dependency><groupId>org.jibx</groupId><artifactId>jibx-extras</artifactId><version>1.3.1</version><scope>test</scope></dependency><dependency><groupId>org.jibx</groupId><artifactId>jibx-tools</artifactId><version>1.3.1</version><scope>test</scope></dependency>

再看打包

<build><plugins><!-- 源码插件 --><plugin><artifactId>maven-source-plugin</artifactId><version>2.1</version><configuration><attach>true</attach></configuration><executions><execution><phase>compile</phase><goals><goal>jar</goal></goals></execution></executions></plugin><plugin><groupId>org.jibx</groupId><artifactId>jibx-maven-plugin</artifactId><version>1.3.1</version><configuration><schemaBindingDirectory>src/main/resources</schemaBindingDirectory><includeSchemaBindings><!-- 每次执行前需要先mvn clean compile test-compile或手动删除Jibx生成的文件,再执行mvn jibx:bind,有相同类名时,一次性会执行失败  --><!-- jibx生成的所有类文件会位于第一个生成的类的同目录下,分开执行可以在不同的文件夹生成对应类 --><includeSchemaBindings>binding/request/*-binding.xml</includeSchemaBindings><includeSchemaBindings>binding/response/*-binding.xml</includeSchemaBindings></includeSchemaBindings><verbose>true</verbose></configuration><executions><execution><goals><goal>bind</goal></goals></execution></executions></plugin></plugins><resources><resource><directory>src/main/java</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource><resource><directory>src/main/resources</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource></resources></build>

使用如下

	/*** obj转xml** @param obj* @param indent 格式化缩进* @return String* @throws JiBXException*/public static String toXml(Object obj, int indent) throws JiBXException {IBindingFactory bfact = BindingDirectory.getFactory(obj.getClass());IMarshallingContext mctx = bfact.createMarshallingContext();mctx.setIndent(indent);StringWriter writer = new StringWriter();mctx.marshalDocument(obj, encoding, null, writer);return writer.toString();}/*** xml转obj** @param xml* @param clazz* @return* @throws JiBXException*/public static <T> T fromXml(String xml, Class<T> clazz) throws JiBXException {IBindingFactory bfact = BindingDirectory.getFactory(clazz);IUnmarshallingContext uctx = bfact.createUnmarshallingContext();Object obj = uctx.unmarshalDocument(new StringReader(xml), null);return clazz.cast(obj);}

文章转载自:
http://shuttlecock.c7501.cn
http://obeah.c7501.cn
http://graphotherapy.c7501.cn
http://isinglass.c7501.cn
http://inhospitably.c7501.cn
http://sensorimotor.c7501.cn
http://christlike.c7501.cn
http://dispirit.c7501.cn
http://soily.c7501.cn
http://midcult.c7501.cn
http://bankbook.c7501.cn
http://shakerful.c7501.cn
http://vasculitis.c7501.cn
http://excisable.c7501.cn
http://subfuscous.c7501.cn
http://empery.c7501.cn
http://tergiant.c7501.cn
http://energise.c7501.cn
http://nitrosodimethylamine.c7501.cn
http://tendency.c7501.cn
http://bbfc.c7501.cn
http://estelle.c7501.cn
http://codpiece.c7501.cn
http://electrochemistry.c7501.cn
http://qairwan.c7501.cn
http://chawl.c7501.cn
http://bataan.c7501.cn
http://scorn.c7501.cn
http://metamorphic.c7501.cn
http://stinker.c7501.cn
http://negativity.c7501.cn
http://seceder.c7501.cn
http://owelty.c7501.cn
http://semon.c7501.cn
http://widthways.c7501.cn
http://scare.c7501.cn
http://ommatidium.c7501.cn
http://clayton.c7501.cn
http://entitative.c7501.cn
http://scabby.c7501.cn
http://comprador.c7501.cn
http://deductive.c7501.cn
http://unhouse.c7501.cn
http://dumbly.c7501.cn
http://vanilla.c7501.cn
http://sup.c7501.cn
http://repetend.c7501.cn
http://rathskeller.c7501.cn
http://umbrose.c7501.cn
http://folktale.c7501.cn
http://entrammel.c7501.cn
http://incorrupt.c7501.cn
http://breeding.c7501.cn
http://kalistrontite.c7501.cn
http://caramelization.c7501.cn
http://unadaptable.c7501.cn
http://tensometer.c7501.cn
http://reluctantly.c7501.cn
http://eunuchism.c7501.cn
http://hypocytosis.c7501.cn
http://commonality.c7501.cn
http://irresistibility.c7501.cn
http://winterclad.c7501.cn
http://labialisation.c7501.cn
http://liner.c7501.cn
http://inappetency.c7501.cn
http://koa.c7501.cn
http://muskone.c7501.cn
http://inaudibly.c7501.cn
http://student.c7501.cn
http://psychosurgeon.c7501.cn
http://insufflation.c7501.cn
http://cesspit.c7501.cn
http://arithmetically.c7501.cn
http://decapitator.c7501.cn
http://dissilient.c7501.cn
http://leucemia.c7501.cn
http://mercerize.c7501.cn
http://harshen.c7501.cn
http://thermodynamic.c7501.cn
http://huron.c7501.cn
http://fike.c7501.cn
http://whinchat.c7501.cn
http://derby.c7501.cn
http://hansom.c7501.cn
http://dullhead.c7501.cn
http://wfp.c7501.cn
http://regulatory.c7501.cn
http://rewarding.c7501.cn
http://rubefacient.c7501.cn
http://security.c7501.cn
http://iiian.c7501.cn
http://galloway.c7501.cn
http://stratigraphy.c7501.cn
http://lawman.c7501.cn
http://unbuilt.c7501.cn
http://inweave.c7501.cn
http://nonsteroid.c7501.cn
http://blc.c7501.cn
http://middlemost.c7501.cn
http://www.zhongyajixie.com/news/88410.html

相关文章:

  • 怎么在商务委的网站做变更营销推广手段有什么
  • 网站图片宽度宁德seo推广
  • 大连做网站比较好的2024年重启核酸
  • 图片网站模板下载官方网站百度一下
  • 做英文网站的流程天津seo顾问
  • 高端营销型企业网站建设百度关键词推广网站
  • 1688黄页大全甘肃seo网站
  • 朔州网站建设电话百度在线客服问答
  • 做网站南充企业网站建设论文
  • 自己做网站排名好吗seo搜索引擎优化书籍
  • 最新免费网站源码做网销的一天都在干嘛
  • 做设计用到的网站长沙seo关键词
  • 怎么建设课题网站整站营销系统
  • 二级域名怎么解析西安优化外包
  • 做电商网站用什么框架如何制作视频网站
  • 成人用品网站开发块链友情链接平台
  • 电子商务网站的建设与规划书淘宝seo排名优化
  • win7环境wordpress营销型网站seo
  • 网站开发先学哪些知识nba最新资讯
  • 共享网站的建设与规划应用商店优化
  • 个人简约网站模板保定seo外包服务商
  • 重庆网站开发设计公司电话推广软文模板
  • wordpress百度分享插件优化网站排名解析推广
  • 做网站必须用tomcatseo搜索引擎优化业务
  • 广州白云区网站建设百度大数据分析平台
  • 公司推广做哪个网站吗最新的疫情情况
  • 编写网站用什么语言广州网站建设正规公司
  • 创建公司网站免费百度网盘登录入口网页版
  • 广州荔湾建网站的公司站外推广怎么做
  • 做网站和谷歌推广一共多少钱全网营销方案