简体   繁体   中英

Referencing JAXB-generated Classes in a Java App

I have an app for which I am thinking of using Java classes generated from an XSD using JAXB. Because of the DRY principle, I feel I should make the class generation part of the build process and not include them in source control.

But, if I do this, how can I write the client code that references the to-be-generated Java classes? I guess the build would work okay, if I compile the code after the class generation, but it seems weird to be writing to a non-existent API (that is only generated at build time).

What is the usual practice for referencing JAXB-generated classes in client code in regard to this problem?

It's absolutely normal. At my previous work we had been living with JAXB-generated classes for three years. So, put ".xsd" files and ant/maven task (wsimport, xjc, etc.) under version control and think about this xsd-files as about primary document. Generated java code in your case is secondary document (like javadocs generated by normal java files). So these documents doesn't deserve to be put under version control (unless you want to do some integrated vcs diff).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM