XJC (XML Java编译器)是 JAXB (Java XML Bindings)的一部分。
如果我查看official website, JAXB 的最新版本似乎 2.2.11 。这是您安装最新JDK版本 8u40 时获得的那个。
以下输出显示与JDK 8u40相关的 XJC 的版本:
../JDK8u40/bin$ ./javac -version
javac 1.8.0_40
../JDK8u40/bin$ ./xjc -version
xjc 2.2.8-b130911.1802
(原始JDK路径因OS而异,因此这只是一个示例性表示。)
XJC 的版本似乎与"最新的" JAXB 版本或最新的JDK不包含最新的JAXB版本。
我的解决方法是从Maven repository安装最新的JAXB版本。听起来很简单,但为什么最新版本的JAXB现在 2.2.12 ?忘了把文件放在官方网站上?好吧,我只是试着不在乎...在成功的安装过程之后,我注意到这个包里面没有 XJC 。继续搜索...我找到了另一个名为" JAXB-XJC"的Maven存储库。但这只是源代码。我只是想安装 XJC 的最新二进制文件。我查看了版本号, 2.2.11 。这看起来至少比2.2.8好。
但是我可以在哪里获得 XJC 的最新二进制文件?
为什么我要安装 XJC 的最新二进制文件?因为我想知道它是否支持Java 8的Optionals和/或它是否支持XSD架构版本1.1。在Internet的某个地方,我读了最新的 XJC ,至少支持XSD架构版本1.1。那就足够了。但要弄清楚这一点,似乎甲骨文必须解决他们可怕的版本混乱。
更新
我尝试通过克隆官方Git repository并执行mvn clean install
来构建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 的二进制文件的异常。那它在哪里?
答案 0 :(得分:1)
我在JAXB maven构建中修复了OSGi故障。所以现在应该没问题。
此外,为了快速构建,您可以尝试使用:
$ mvn clean install -Ddev
这将在不创建docs / osgi-tests的情况下运行快速构建。
您还可以在jaxb-ri.zip
中找到遗留$JAXB_HOME/bundles/ri/target/
(包含bin / libs / examples /)。或者,如果您不希望每次在构建后将其解压缩,请直接转到:$JAXB_HOME/bundles/ri/target/stage/jaxb-ri/
。
PS:如果您使用的是独立的JAXB,请不要忘记将JAVA endorsed mechanism用于jaxb-api.jar。