XJC(XMLJava编译器)是JAXB(JavaXML绑定)的一部分。
如果我看官网链接,最新版本的JAXB似乎是2.2.11。这是你刚刚安装最新JDK版本8u40时得到的。
以下输出显示了与JDK8u40相关的XJC版本:
../JDK8u40/bin$ ./javac -version
javac 1.8.0_40
../JDK8u40/bin$ ./xjc -version
xjc 2.2.8-b130911.1802
(原始JDK路径从OS到OS不同,因此这只是一个示例性表示。)
XJC的版本似乎不同于“最新”的JAXB版本,或者最新的JDK不包含最新的JAXB版本。
我的解决方法是只从Maven存储库安装最新的JAXB版本。听起来很容易,但是为什么现在JAXB的最新版本是2.2.12?忘记把留档放在官方网站上了?好吧,我只是试着不在乎…安装成功后我注意到这个包里面没有XJC。所以继续搜索…我找到了另一个名为“JAXB-XJC”的Maven存储库。但这只是源代码。我只是想安装XJC的最新二进制文件。我看了版本号,是2.2.11。那看起来至少比2.2.8好。
但是我在哪里可以获得XJC的最新二进制文件?
为什么我要安装最新的XJC二进制文件?因为我想知道它是否支持Java8的选项和/或是否支持XSD模式版本1.1。在互联网上的某个地方,我读到最新的XJC至少支持XSD模式版本1.1。这就足够了。但是为了解决这个问题,甲骨文似乎必须修复他们可怕的版本混乱。
更新
我试图通过克隆官方Git存储库并执行mvn清洁安装
来构建JAXB。
结果:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] JAXB BOM ........................................... SUCCESS [ 0.140 s]
[INFO] JAXB BOM with ALL dependencies ..................... SUCCESS [ 0.005 s]
[INFO] JAXB Reference Implementation ...................... SUCCESS [ 0.515 s]
[INFO] JAXB External parent ............................... SUCCESS [ 0.009 s]
[INFO] RNGOM .............................................. SUCCESS [ 3.723 s]
[INFO] Codemodel .......................................... SUCCESS [ 0.008 s]
[INFO] Codemodel Core ..................................... SUCCESS [ 2.622 s]
[INFO] Codemodel Annotation Compiler ...................... SUCCESS [ 0.848 s]
[INFO] JAXB TXW parent .................................... SUCCESS [ 0.006 s]
[INFO] TXW2 Runtime ....................................... SUCCESS [ 1.920 s]
[INFO] TXW2 Compiler ...................................... SUCCESS [ 1.507 s]
[INFO] JAXB Core .......................................... SUCCESS [ 1.745 s]
[INFO] JAXB Runtime parent ................................ SUCCESS [ 0.008 s]
[INFO] JAXB Runtime ....................................... SUCCESS [ 5.932 s]
[INFO] JAXB1 Runtime ...................................... SUCCESS [ 1.520 s]
[INFO] JAXB XJC ........................................... SUCCESS [ 5.555 s]
[INFO] JAXB JXC ........................................... SUCCESS [ 2.928 s]
[INFO] Parent for osgi testing modules. ................... SUCCESS [ 0.009 s]
[INFO] osgi-test-parent ................................... SUCCESS [ 1.315 s]
[INFO] osgi-test-core ..................................... SUCCESS [ 0.676 s]
[INFO] JAXB bundles ....................................... SUCCESS [ 0.007 s]
[INFO] Old JAXB Core ...................................... SUCCESS [ 4.669 s]
[INFO] osgi-test-runtime .................................. SUCCESS [ 0.677 s]
[INFO] Old JAXB Runtime ................................... SUCCESS [ 3.251 s]
[INFO] osgi-test-xjc ...................................... SUCCESS [ 0.637 s]
[INFO] Old JAXB XJC ....................................... SUCCESS [ 4.385 s]
[INFO] osgi-test-jxc ...................................... SUCCESS [ 0.607 s]
[INFO] Old JAXB JXC ....................................... SUCCESS [ 2.169 s]
[INFO] JAXB Documentation parent .......................... SUCCESS [ 0.005 s]
[INFO] JAXB Release Documentation ......................... SUCCESS [ 12.401 s]
[INFO] JAXB samples ....................................... SUCCESS [ 0.375 s]
[INFO] JAXB RI ............................................ SUCCESS [ 1.079 s]
[INFO] JAXB OSGI parent ................................... SUCCESS [ 0.005 s]
[INFO] JAXB extra OSGI .................................... FAILURE [ 6.668 s]
[INFO] JAXB OSGI .......................................... SKIPPED
[INFO] osgi-test-osgi ..................................... SKIPPED
[INFO] osgi-test-extra_osgi ............................... SKIPPED
[INFO] JAXB OSGi Tests .................................... SKIPPED
[INFO] JAXB WWW Help files ................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:08 min
[INFO] Finished at: 2015-03-11T15:40:59+01:00
[INFO] Final Memory: 83M/1546M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.0:shade (default) on project jaxb-extra-osgi: Error creating shaded jar: java.util.jar.Attributes cannot be cast to java.lang.String -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :jaxb-extra-osgi
JAXB额外OSGI目标的构建过程总是失败。JAXB XJC目标构建成功,但只包含一个抛出jar文件的异常,但没有名为xjc的二进制文件。那么它在哪里?
我已经在JAXB maven build中修复了OSGi故障。所以现在应该没问题了。
此外,要快速构建,您可以尝试使用:
$ mvn clean install -Ddev
这将在不创建文档/osgi-test的情况下运行快速构建。
您还可以在$JAXB_HOME/bundles/ri/target/
中找到遗留的jaxb-ri.zip
(带有bin/libs/示例/)。或者如果您不想每次构建后都解压缩它,请直接访问:$JAXB_HOME/bundles/ri/target/阶段/jaxb-ri/
。
PS:如果您使用独立的JAXB,请不要忘记为jaxb-api. jar使用JAVA认可的机制。