最近、JAXBによって生成されたJavaクラスの2つのバージョンを生成しました。だから私は2つのパッケージを手に入れます:V1_0とV2_0
ObjectFactoryが1つだけ生成されていることに気付きました。問題は、このObjectFactoryがバージョンに固有であるということです(ここでは、私のバージョンv1_0に固有です)。
したがって、質問は次のとおりです。バージョンごとに1つのObjectFactoryを作成できるようにJAXBを構成できますか?
どうもありがとう。
最近、JAXBによって生成されたJavaクラスの2つのバージョンを生成しました。だから私は2つのパッケージを手に入れます:V1_0とV2_0
ObjectFactoryが1つだけ生成されていることに気付きました。問題は、このObjectFactoryがバージョンに固有であるということです(ここでは、私のバージョンv1_0に固有です)。
したがって、質問は次のとおりです。バージョンごとに1つのObjectFactoryを作成できるようにJAXBを構成できますか?
どうもありがとう。
If the two versions of the API are in the same namespace, that's horrible! You'll have the object factory from one round of generation overwriting the object factory produced by the other (or inhibiting; I forget which xjc
actually does). It's also horrible for clients of the API since they won't know what version of the API they're dealing with (unless you're doing other nasty tricks, which ought to be discouraged; if they're in the same namespace they should be the same API).
The fix is to put the two APIs in different namespaces so that they get generated into different packages with different object factories. (Also beware of any use of the -p
option to xjc
; that can cause things to go into the same namespace and give you these overwriting headaches.)
両方のバージョンで 1 つのオブジェクト ファクトリですか? いいえ、それは不可能です。2 つのパッケージで 2 セットのクラスを取得します。1 つのオブジェクト ファクトリで両方を提供することはできません。