Update from Jaxb 1 to Jaxb 2

I want to update our jaxb version of the project from 1 to 2. Has anyone tried to do this in their projects and are there any tips someone wants to do? I understand that each project is unique, I'm just looking for general advice.

+3
source share
2 answers

JAXB2 will generate enum classes for type constraints. Any Java code that relies on setting string values ​​to use these types will require the use of an appropriate enumeration. I think this is great, since you get type checking at compilation, and not during checking for validation.

JABX2 uses typed lists instead of untyped lists, so you can remove many castings from your java code.

. IIRC, JAXB1 , JAXB2 XMLGregorianCalendar.

+4

JAXB 1 JAXB 2.1 ( JavaSE 6). XSD , :

<xs:element name="logging">
        <xs:complexType>
                <xs:attribute name="debug" type="xs:boolean" use="required"/>
                <xs:attribute name="file" type="xs:string" use="required"/>
        </xs:complexType>
</xs:element>

, , JAXB 1.0 LoggingType ( ), JAXB 2 Logging. , , . , , - .

+1

Source: https://habr.com/ru/post/1699241/


All Articles