Does JAXB work under Java 5?(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 下工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:JAXB 在 Java 5 下工作吗?


基础教程推荐
- 降序排序:Java Map 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01