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

查看:71
本文介绍了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天全站免登陆