eclipse xsd 生成java,Generate XSD from JAXB Java Classes using Eclipse

学习使用Eclipse IDE 从带有JAXB注释的Java类创建XML模式文档(xsd) 。

1) Add JAXB Annotations to Java Classes

第一步是在Java类中添加@XmlRootElement , @XmlAccessorType和@XmlElement等注释。

import java.io.Serializable;

import javax.xml.bind.annotation.XmlAccessType;

import javax.xml.bind.annotation.XmlAccessorType;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "employee")

@XmlAccessorType(XmlAccessType.PROPERTY)

public class Employee implements Serializable {

private static final long serialVersionUID = 1L;

private Integer id;

private String firstName;

private String lastName;

private Department department;

public Employee() {

super();

}

//Setters and Getters

}import java.io.Serializable;

import javax.xml.bind.annotation.XmlAccessType;

import javax.xml.bind.annotation.XmlAccessorType;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "department")

@XmlAccessorType(XmlAccessType.PROPERTY)

public class Department implements Serializable {

private static final long serialVersionUID = 1L;

Integer id;

String name;

public Department() {

super();

}

//Setters and Getters

}

2) Generate XSD from JAXB Classes

2.1) Navigate to Eclipse OptionFile -> New -> JAXB -> Schema from JAXB Classes73461afad3cd2b57b0008599ad4d4c21.pngSchema from JAXB Classes Option

2.2) Select location for generated schema file

e91457f56f596603212e6a98cb5381d0.pngLocaion of Generated Schema File

2.3) Select JAXB Classes

4df76d9f44b018ee59669875c5a0ef28.pngChoose JAXB Classes

2.4) Generate xsd files<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

XSd文件已生成,现在您可以将其用于各种应用程序用例。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值