相关文章推荐
神勇威武的炒饭  ·  Google earth ...·  1 年前    · 
卖萌的鸡蛋面  ·  node.js ...·  1 年前    · 
温文尔雅的蟠桃  ·  How do I use ...·  1 年前    · 
豪情万千的芒果  ·  Python基础 ...·  1 年前    · 
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import lombok.Data; import lombok.experimental.Accessors; import java.util.List; * 定义信号控制传输对象 * @JacksonXmlRootElement: 用在类上,用来自定义根节点名称; * @JacksonXmlProperty: 用在属性上,用来自定义子节点名称; * @JacksonXmlElementWrapper: 用在属性上,可以用来嵌套包装一层父节点,或者禁用此属性参与 XML 转换。 @Data @JacksonXmlRootElement(localName = "Message" ) @Accessors(chain = true ) public class SystemSignalControlMessage extends MessageCommonField { @JacksonXmlElementWrapper(localName = "Body" ) @JacksonXmlProperty(localName = "Body" ) private Body body; @Data public static class Body { @JacksonXmlElementWrapper(localName = "Operation" ) @JacksonXmlProperty(localName = "Operation" ) private Operation operation; @Data public static class Operation { // 路口控制方式参数对象 @JacksonXmlElementWrapper(localName = "TSCCmd" ) @JacksonXmlProperty(localName = "TSCCmd" ) private TSccMd tSCCmd; @JacksonXmlProperty(localName = "order",isAttribute = true ) private String order; @JacksonXmlProperty(localName = "name",isAttribute = true ) private String name; * 路口控制方式参数对象 @Data public static class TSccMd { * 指定控制方式 @JacksonXmlElementWrapper(localName = "CrossControlMode" ) @JacksonXmlProperty(localName = "CrossControlMode" ) private CrossControlMode crossControlMode; * 多个锁定交通流向 @JacksonXmlElementWrapper(localName = "LockFlowDirection" ) @JacksonXmlProperty(localName = "LockFlowDirection" ) private List<LockFlowDirection> lockFlowDirection; * 指定控制方案 @JacksonXmlElementWrapper(localName = "CrossPlan" ) @JacksonXmlProperty(localName = "CrossPlan" ) private CrossPlan crossPlan; * 指定阶段-扩展参数 @JacksonXmlElementWrapper(localName = "CrossStage" ) @JacksonXmlProperty(localName = "CrossStage" ) private CrossStage crossStage; * 中心临时方案控制-扩展参数 @JacksonXmlElementWrapper(localName = "TemporaryControlPlan" ) @JacksonXmlProperty(localName = "TemporaryControlPlan" ) private TemporaryControlPlan temporaryControlPlan; * 中心临时方案控制-扩展对象 @Data public static class TemporaryControlPlan { @JacksonXmlProperty(localName = "CrossID" ) private String crossID; @JacksonXmlProperty(localName = "CycleLen" ) private String cycleLen; @JacksonXmlProperty(localName = "CoordStageNo" ) private String coordStageNo; @JacksonXmlProperty(localName = "OffSet" ) private String offSet; @JacksonXmlProperty(localName = "StagePlanNo" ) private String stagePlanNo; @JacksonXmlProperty(localName = "PlanNo" ) private String planNo; @JacksonXmlElementWrapper(useWrapping = false ) @JacksonXmlProperty(localName = "StageNoList" ) private List<StageNoList> stageNoLists; * 指定阶段-扩展对象 @Data public static class StageNoList { @JacksonXmlProperty(localName = "SeqNo" ) private String seqNo; @JacksonXmlProperty(localName = "StageNo" ) private String stageNo; @JacksonXmlProperty(localName = "StageTime" ) private String stageTime; * 指定阶段-扩展对象 @Data public static class CrossStage { @JacksonXmlProperty(localName = "CrossID" ) private String crossID; @JacksonXmlProperty(localName = "StageNo" ) private String stageNo; * 指定控制方案对象 @Data public static class CrossPlan { @JacksonXmlProperty(localName = "CrossID" ) private String crossID; @JacksonXmlProperty(localName = "PlanNo" ) private String planNo; * 路口控制方式对象 @Data public static class CrossControlMode { @JacksonXmlProperty(localName = "CrossID" ) private String crossID; @JacksonXmlProperty(localName = "Value" ) private String value; * 锁定交通流向对象 @Data public static class LockFlowDirection { @JacksonXmlProperty(localName = "CrossID" ) private String crossID; @JacksonXmlProperty(localName = "Type" ) private String type; @JacksonXmlProperty(localName = "Entrance" ) private String entrance; @JacksonXmlProperty(localName = "Exit" ) private String exit; @JacksonXmlProperty(localName = "StartTime" ) private String startTime; @JacksonXmlProperty(localName = "Duration" ) private String duration;
        <!--        jackson-dataformat-xml是xml和bean转换依赖的包-->
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>

参考:https://blog.51cto.com/wuyongyin/5684578

https://www.cnblogs.com/scai-fxh/p/10598535.html