jaxb之xjc编码问题
平时喜欢根据写一个xjc批处理命令,根据xsd批量生成java类,觉得很方便也很酷。但是有时候xsd生成的java类中含有汉字,结果总是有些问题。
可是xjc命令参数又没有encoding参数之类的。在网上搜了一通,忽然发现了一个好东东:xjc是由com.sun.tools.internal.xjc.Driver实现的,因此
批处理命令可以如下:
java -Dfile.encoding=UTF-8 -cp D:\java\jdk1.6.0_03\lib\tools.jar com.sun.tools.internal.xjc.Driver -p com.geostar.csw.domain.layer metadata_geo_Layer.xsd
结果:
parsing a schema...
compiling a schema...
com\geostar\csw\domain\layer\AbstractMDContentInformationType.java
com\geostar\csw\domain\layer\AbstractMDIdentificationType.java
com\geostar\csw\domain\layer\AbstractMDSpatialRepresentationType.java
com\geostar\csw\domain\layer\CIAddressType.java
com\geostar\csw\domain\layer\CICitationType.java
com\geostar\csw\domain\layer\CIContactType.java
com\geostar\csw\domain\layer\CIDateType.java
com\geostar\csw\domain\layer\CIDateTypeCode.java
com\geostar\csw\domain\layer\CIOnLineFunctionCode.java
com\geostar\csw\domain\layer\CIOnLineResourceType.java
com\geostar\csw\domain\layer\CIResponsiblePartyType.java
com\geostar\csw\domain\layer\CIRoleCode.java
com\geostar\csw\domain\layer\DQDataLineageType.java
com\geostar\csw\domain\layer\DQDataQualityType.java
com\geostar\csw\domain\layer\DQDqReportType.java
com\geostar\csw\domain\layer\DQDqStatementType.java
com\geostar\csw\domain\layer\DQSourceType.java
com\geostar\csw\domain\layer\DSAssociationTypeCode.java
com\geostar\csw\domain\layer\EXBoundingCoordinatesType.java
com\geostar\csw\domain\layer\EXExtentType.java
com\geostar\csw\domain\layer\EXGeographicBoundingBoxType.java
com\geostar\csw\domain\layer\EXGeographicBoundingPolygonType.java
com\geostar\csw\domain\layer\EXGeographicDescriptionType.java
com\geostar\csw\domain\layer\EXGeographicExtentPropertyType.java
com\geostar\csw\domain\layer\EXGeographicExtentType.java
com\geostar\csw\domain\layer\EXTemporalExtentPropertyType.java
com\geostar\csw\domain\layer\EXTemporalExtentType.java
com\geostar\csw\domain\layer\EXVerticalExtentType.java
com\geostar\csw\domain\layer\FBZY.java
com\geostar\csw\domain\layer\JHDA.java
com\geostar\csw\domain\layer\MDAerialImageIdentificationType.java
com\geostar\csw\domain\layer\MDAggregateInfomationPropertyType.java
com\geostar\csw\domain\layer\MDAggregateInfomationType.java
com\geostar\csw\domain\layer\MDAnalogMapIdentificationType.java
com\geostar\csw\domain\layer\MDApprovedTypeCode.java
com\geostar\csw\domain\layer\MDArchiveIdentificationType.java
com\geostar\csw\domain\layer\MDBrowseGraphicType.java
com\geostar\csw\domain\layer\MDCRSType.java
com\geostar\csw\domain\layer\MDCharacterSetCode.java
com\geostar\csw\domain\layer\MDClassificationCode.java
com\geostar\csw\domain\layer\MDConstraintsPropertyType.java
com\geostar\csw\domain\layer\MDContentInformationPropertyType.java
com\geostar\csw\domain\layer\MDCoverageContentTypeCode.java
com\geostar\csw\domain\layer\MDCoverageDescriptionType.java
com\geostar\csw\domain\layer\MDDataIdentificationType.java
com\geostar\csw\domain\layer\MDDescKeys.java
com\geostar\csw\domain\layer\MDDigitalArchiveIdentificationType.java
com\geostar\csw\domain\layer\MDDistributionType.java
com\geostar\csw\domain\layer\MDDistributorType.java
com\geostar\csw\domain\layer\MDEllipsoidParametersType.java
com\geostar\csw\domain\layer\MDFeatureCatalogueDescriptionType.java
com\geostar\csw\domain\layer\MDFormatType.java
com\geostar\csw\domain\layer\MDGeometricObjectTypeCode.java
com\geostar\csw\domain\layer\MDGovNameTypeBak.java
com\geostar\csw\domain\layer\MDGridSpatialRepresentationType.java
com\geostar\csw\domain\layer\MDIdentificationPropertyType.java
com\geostar\csw\domain\layer\MDIdentifierType.java
com\geostar\csw\domain\layer\MDImageDescriptionType.java
com\geostar\csw\domain\layer\MDImageIdentificationType.java
com\geostar\csw\domain\layer\MDImagingConditionCode.java
com\geostar\csw\domain\layer\MDLegConstsType.java
com\geostar\csw\domain\layer\MDMaintInformationType.java
com\geostar\csw\domain\layer\MDMaintenanceFrequencyCode.java
com\geostar\csw\domain\layer\MDMapFormCode.java
com\geostar\csw\domain\layer\MDMetadataType.java
com\geostar\csw\domain\layer\MDProgressCode.java
com\geostar\csw\domain\layer\MDProjectionParametersType.java
com\geostar\csw\domain\layer\MDReferenceSystemType.java
com\geostar\csw\domain\layer\MDReferencedThemeType.java
com\geostar\csw\domain\layer\MDResolutionType.java
com\geostar\csw\domain\layer\MDResourceTypeCode.java
com\geostar\csw\domain\layer\MDRestrictionCode.java
com\geostar\csw\domain\layer\MDRestrictionCodeEx.java
com\geostar\csw\domain\layer\MDScopeCode.java
com\geostar\csw\domain\layer\MDSecurityConstraintsType.java
com\geostar\csw\domain\layer\MDSpatialRepresentationPropertyType.java
com\geostar\csw\domain\layer\MDSpatialRepresentationTypeCode.java
com\geostar\csw\domain\layer\MDTopicCategoryCode.java
com\geostar\csw\domain\layer\MDTopoLogyLevelCode.java
com\geostar\csw\domain\layer\MDTpCatType.java
com\geostar\csw\domain\layer\MDVectorSpatialRepresentationType.java
com\geostar\csw\domain\layer\ObjectFactory.java
com\geostar\csw\domain\layer\SVOperationMetadataType.java
com\geostar\csw\domain\layer\SVServiceIdentificationType.java
com\geostar\csw\domain\layer\SpatialReferenceInfo.java
com\geostar\csw\domain\layer\TBOOL.java
com\geostar\csw\domain\layer\TDYTABLETYPE.java
com\geostar\csw\domain\layer\TDataInfo.java
com\geostar\csw\domain\layer\TJHSJ.java
com\geostar\csw\domain\layer\TJHTYPE.java
com\geostar\csw\domain\layer\TJHXX.java
com\geostar\csw\domain\layer\TLAYERTYPE.java
com\geostar\csw\domain\layer\TMInstantType.java
com\geostar\csw\domain\layer\TMPeriodType.java
com\geostar\csw\domain\layer\TMetaInfo.java
com\geostar\csw\domain\layer\TMetaTotal.java
com\geostar\csw\domain\layer\TTABLETYPE.java
com\geostar\csw\domain\layer\TTHMEATICTYPE.java
com\geostar\csw\domain\layer\TUPDATETYPE.java
com\geostar\csw\domain\layer\TUserInfo.java
com\geostar\csw\domain\layer\TVersionInfo.java
com\geostar\csw\domain\layer\TZDGL.java
com\geostar\csw\domain\layer\TZDJH.java
com\geostar\csw\domain\layer\UpdateDescribe.java
com\geostar\csw\domain\layer\package-info.java
c:\Catalog实体类生成工具>
忽然感觉好兴奋!jaxb真的是好东东!
转载请注明出处:http://www.cnblogs.com/likehua