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 下工作吗?
基础教程推荐
- Maven:无效的目标版本:10 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- JPA惰性列表上的流 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
