jaxb

jdk8以上会出现的JAXB问题

血红的双手。 提交于 2020-08-12 18:44:39
<!--解决JDK8以上版本 JAXB问题--> < dependency > < groupId > javax.xml.bind </ groupId > < artifactId > jaxb-api </ artifactId > < version > 2.3.0 </ version > </ dependency > < dependency > < groupId > com.sun.xml.bind </ groupId > < artifactId > jaxb-impl </ artifactId > < version > 2.3.0 </ version > </ dependency > < dependency > < groupId > com.sun.xml.bind </ groupId > < artifactId > jaxb-core </ artifactId > < version > 2.3.0 </ version > </ dependency > < dependency > < groupId > javax.activation </ groupId > < artifactId > activation </ artifactId > < version > 1.1.1 </ version > </ dependency

使用JDK原生类实现xml序列化返序列化

南楼画角 提交于 2020-08-09 22:47:04
先看目录结构 xml序列化+返序列化工具 package com.yh.xml; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation. XmlNs ; import javax.xml.bind.annotation. XmlSchema ; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.transform.stream.StreamResult; import java.io.StringReader; import java.io.StringWriter; public class XmlDemo { public static void main(String[] args) throws JAXBException { JAXBContext jc = JAXBContext. newInstance (Domain. class ); //复合对象 Domain domain = new Domain(); D d = new D(); d.setParam1( "p1" ); d

HowToDoInJava 其它教程 2 · 翻译完毕

坚强是说给别人听的谎言 提交于 2020-08-09 16:32:52
原文: HowToDoInJava 协议: CC BY-NC-SA 4.0 欢迎任何人参与和完善:一个人可以走的很快,但是一群人却可以走的更远。 ApacheCN 学习资源 目录 JMS 教程 JMS 教程 – Java 消息服务教程 JMS 点对点消息示例 JMS 发布/订阅消息示例 HornetQ 教程 HornetQ 单体 – 基本的 JMS 消息传递示例 使用 Maven 的 HornetQ 独立服务器示例 Spring3 Hornetq 独立集成示例 Gson 教程 Gson 教程 Gson 安装 GSON – 序列化和反序列化 JSON Gson – JSON 输出的精美打印 GSON – 将 JSON 数组解析为 Java 数组或列表 GSON – 序列化和反序列化 JSON 为集 Gson – 序列化和反序列化包含自定义对象的 HashMap Gson – GsonBuilder 配置示例 Gson - 序列化 NULL 值 Gson @Since – 版本支持 Gson @SerializedName Gson – 排除或忽略字段 Gson - JsonReader Gson - JsonParser Gson – 自定义序列化和反序列化 Gson – 快速指南 JAXB 教程 JAXB 注解 JAXB @XmlRootElement 注解示例 JAXB

JAXB attributes using underscore

本小妞迷上赌 提交于 2020-07-30 07:26:32
问题 I working on JAXB to using java object I am creating xml.But im using javaclass fields Like qpack_id as attrubute it creating in xml file like qpackId so how can i use _(underscore) in jaxB please guide me. xml file should create bellow attibute <qpack " qpack_id="MB0046_SET4" qpack_name="MB0046"> </qpack> 回答1: Starting from Java Classes You can use the XmlAttribute annotation to specify a name. @XmlAttribute(name="qpack_name") public String getQPackName() { return qPackName; } Starting from

JAXB Unmarshalling issues with XML attributes

人走茶凉 提交于 2020-07-18 20:14:05
问题 I am having an issue unmarshalling with JAXB for an XML file. There is an attribute on some of the xml elements called "display_value" which I need to obtain. Here is a small example of the XML file: <unload> <change_request> <active>true</active> <approval>not requested</approval> <assigned_to display_value=""/> <alt_poc display_value="Tom Ford">056468745677484657</alt_poc> <poc display_value="Matt Ryan">56465148754878</poc> </change_request> </unload> I assume that in my ChangeRequest class

XML (with namespace) to Object unmarshalling

落爺英雄遲暮 提交于 2020-07-06 12:16:11
问题 I got following repsonse from a Web service call, I tried to unmarshal the same using JAXB to map it to a java class. I was getting unmarshal exception while doing so. <?xml version="1.0" encoding="UTF-8"?> <ns0:QueryByLNResponse xmlns:ns0="UIS_CTMPeople_WS" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ns0:getListValues> <ns0:First_Name>Pradeep</ns0:First_Name> <ns0:Internet_E

Marshalling CDATA elements with CDATA_SECTION_ELEMENTS adds carriage return characters

断了今生、忘了曾经 提交于 2020-06-27 17:58:07
问题 I'm working on an application that exports and imports data from / to a DB. The format of the data extract is XML and I'm using JAXB for the serialization / (un)marshalling. I want some elements to be marshalled as CDATA elements and am using this solution which sets OutputKeys.CDATA_SECTION_ELEMENTS to the Transformer properties. So far this was working quite well, but now I came to a field in the DB that itself contains an XML string, which I also would like to place inside of a CDATA

Replacing XmlType.namespace using jaxb bindings during type generation

≡放荡痞女 提交于 2020-06-27 08:40:51
问题 My web-services application is moving from Axis to JAX-WS and I'm having trouble doing some of the conversions. My primary issue is that I have several XSD's with the same types defined slightly differently, but with the same names. During my wsimport I'm able to use an external JAXB bindings file to resolve the packages, but the generated classes still end up with the same @XmlType annotations. V1: package com.service.v1.bill.request; @XmlType(name = "FileBillReqType", namespace = "http:/

Force escaping Special character in XML Marshalling in Spring

廉价感情. 提交于 2020-06-25 03:37:30
问题 I want to force escaping special characters when I use Spring Marshaller. Below code is perfectly working when I use javax.xml.bind.Marshaller Book Class package com.odr.core.action; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRegistry; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name

JAXB remove XmlRootElement wrapper

淺唱寂寞╮ 提交于 2020-06-24 12:38:00
问题 I have this @XmlRootElement class Person. @XmlRootElement class Person { private String desc; } and the return content is {"Person": {"desc": "abc"} } and I really don't want the root wrapper, so I want the content to looks like {"desc": "abc"} Can I accomplish this via JaxB? If so, how? Thanks! 回答1: JAXB is an API for XML, not JSON. However, there are some JSON libraries (at least Jackson) which can utilize JAXB annotations. I don't know which one you are using, so I don't know exactly how