问题
I came accross the xdoclet project and see it enjoys/ed high popularity. So the question is, now that we have annotations in java: is xdoclet legacy?
Or is there something to xdoclet I didn't see/understand.
回答1:
XDoclet
is an annotation implementation via JavaDoc
. Anything that could be done with XDoclet
(and much more) can be done with JDK5+
annotations.
One obvious difference however is that XDoclet
is non-invasive. That is, it doesn't require you to import classes into your own code. If you are using 3rd-party Java annotations in your own code, then of course you cannot build your code without the 3rd party jars present. This is not a drawback that XDoclet suffers from. (You may not see it as a drawback at all.)
Of course, even though XDoclet
may be legacy, I suspect that for most projects which have relied heavily on it, there will be no rush to migrate to using annotations (maxim: if it ain't broke, don't fix it).
回答2:
Hopefully XDoclet is history. As has been pointed out, you need to include some kind of artifact from the provider of the annotation, usually some kind of api module. This only enforces the strong typing aspects that we're so used to in java, allowing all sorts of of automated tracking/tracing and proper tool support in all modern ide's.
来源:https://stackoverflow.com/questions/611473/now-that-we-have-annotations-in-java-is-xdoclet-legacy