JAXB 在 Java 5 下工作吗? [英] Does JAXB work under Java 5?

查看:16
本文介绍了JAXB 在 Java 5 下工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 maven 构建我得到包 javax.xml.bind.annotation 不存在"

Building with maven I get "package javax.xml.bind.annotation does not exist"

我需要什么才能使 JAXB 与 Java 5 一起使用?

What do I need to make JAXB work with Java 5?

推荐答案

JAXB API 捆绑在 JDK1.6 中,但在 JDK <1.6(例如:JDK1.5)中不可用.

JAXB APIs are bundled in JDK1.6, but these are not available in JDK <1.6 (ex: JDK1.5).

我有一个用 JDK1.6 编写的 Java 到 XML 代码,一旦我切换到 JDK1.5,我得到以下错误:

I have a Java to XML code written in JDK1.6 and once I switched to JDK1.5, I got the following error:

*Exception in thread "main" java.lang.RuntimeException: javax.xml.bind.JAXBException
 - with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
...
Caused by: javax.xml.bind.JAXBException
 - with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]*
...

JDK1.5 不包含 JAXB API,因此我应用了以下修复:我在类路径中使用了JDK1.5和以下两个JARS:jaxb-api-2.0.jar和jaxb-impl-2.0.jar,错误已解决.

JDK1.5 doesnt contain the JAXB APIs and therefore I applied the following fix: I used JDK1.5 and the following two JARS: jaxb-api-2.0.jar and jaxb-impl-2.0.jar in my classpath and the error was resolved.

我希望这会有所帮助.另一个参考:http://www.mkyong.com/java/jaxb-hello-world-example/

I hope this helps. Another Reference: http://www.mkyong.com/java/jaxb-hello-world-example/

这篇关于JAXB 在 Java 5 下工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆