我应该在Maven项目中为JAXB RI使用哪些工件? [英] Which artifacts should I use for JAXB RI in my Maven project?
问题描述
历史上,我总是在我的Maven项目中使用以下JAXB RI工件:
Historically, I always used the following JAXB RI artifacts in my Maven projects:
-
com.sun。 xml.bind:jaxb-impl
- 运行时 -
com.sun.xml.bind:jaxb-xjc
- 模式编译器 -
com.sun.xml.bind:jaxb-jxc
- 模式生成器
com.sun.xml.bind:jaxb-impl
- Runtimecom.sun.xml.bind:jaxb-xjc
- Schema compilercom.sun.xml.bind:jaxb-jxc
- Schema generator
由于大约版本 2.2.10 *
这些工件现在是描述为旧:
Since approximately version 2.2.10*
these artifacts are now described as "old":
com.sun.xml.bind:jaxb-impl
旧的JAXB运行时模块。
Old JAXB Runtime module.
所以看起来这些工件现在已经过时了。
So it looks like these artifacts are now obsolete.
问题是:
应该使用哪些工件?
推荐答案
在使用Oracle澄清后,应使用以下工件:
After clarification with Oracle, the following artifacts should be used:
如果您希望将XML解组为Java对象或将Java对象编组为XML:
If you want to unmarshal XML to Java objects or marshal Java objects as XML:
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>...</version>
</dependency>
架构编译器(XJC)
如果你有一个XML Schema,并希望从中生成Java代码:
Schema compiler (XJC)
If you have an XML Schema and want to generate the Java code out of it:
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>...</version>
</dependency>
架构生成器(JXC / schemagen
)
如果你有带有JAXB注释的Java类,并希望基于它们生成XML Schema:
Schema generator (JXC/schemagen
)
If you have Java classes with JAXB annotations and want to generate a XML Schema based on them:
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-jxc</artifactId>
<version>...</version>
</dependency>
后两个工件( org.glassfish.jaxb:jaxb-xjc
和 org.glassfish.jaxb:jaxb-jxc
)由Maven插件包装,因此通常在运行时不需要它们。
The two latter artifacts (org.glassfish.jaxb:jaxb-xjc
and org.glassfish.jaxb:jaxb-jxc
) are wrapped by Maven plugins so you normally would not need them in the runtime.
如果你的Maven项目不知道得到完整的类路径,打开调试输出并检查Maven控制台。您可能会看到以下错误消息:
If your Maven projects somehow don't get the full classpath, turn on debug output and check the Maven console. You might be seeing the following error message there:
[错误]'dependencyManagement.dependencies.dependency.systemPath'for com.sun:tools :jar必须指定绝对路径,但是$ {tools.jar} @
[ERROR] 'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} @
这是由于以下问题:
解决方案是将 -vm
选项添加到 eclipse.ini
:
-vm
<PATH_TO_JDK>\jre\bin\javaw.exe
这篇关于我应该在Maven项目中为JAXB RI使用哪些工件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!