eclipse 从模式生成 jaxb 类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9873830/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Generating jaxb classes from a schema
提问by Erik Sapir
I am trying to use the Jaxb classes generator in eclipse to generate jaxb classes from my schema. I receive the following error:
我正在尝试使用 eclipse 中的 Jaxb 类生成器从我的架构中生成 jaxb 类。我收到以下错误:
"The classpath for this project does not appear to contain the necessary libraries to proceed with class generation. Please insure that a JAXB implementation is available on the classpath."
“该项目的类路径似乎不包含继续生成类所需的库。请确保 JAXB 实现在类路径上可用。”
How can i solve this problem?
我怎么解决这个问题?
采纳答案by nwinkler
Make sure to include the jaxb-impl.jar
library in your project. You can download one for example from here:
http://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.2.4/jaxb-impl-2.2.4.jar
确保jaxb-impl.jar
在您的项目中包含该库。例如,您可以从这里下载一个:http:
//repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.2.4/jaxb-impl-2.2.4.jar
If you're using Maven, you can include this as a dependency, otherwise download the file and add it as a library in your project.
如果您使用 Maven,则可以将其作为依赖项包含在内,否则下载该文件并将其作为库添加到您的项目中。
If you need a different version of the library, move up one directory in the link that I added above, you can find other versions there as well.
如果您需要不同版本的库,请在我上面添加的链接中向上移动一个目录,您也可以在那里找到其他版本。
If you want to automate the class generation, since you're changing the schema on a regular basis, you should automate the process, e.g through Maven.
如果您想自动生成类,因为您要定期更改模式,您应该自动执行该过程,例如通过 Maven。
回答by Amzi
After a lot of research here is what I have done to fix the issue. Windows> Preferences> Java> InstalledJREs...make sure to point your jre to the jdk directory. I was pointing to JRE and as soon as I changed it to JDK, it started working. Hope this will help you guys.
经过大量研究,这里是我为解决该问题所做的工作。Windows> Preferences> Java> InstalledJREs...确保将您的 jre 指向 jdk 目录。我指的是 JRE,一旦我将其更改为 JDK,它就开始工作。希望这会帮助你们。
回答by Shaini Sinha
Windows> Preferences> Java> InstalledJREs > Execution Environment. Select an environment JDK 1.8 and then try to create JAXB Classes.
Windows> 首选项> Java> InstalledJREs > 执行环境。选择环境 JDK 1.8,然后尝试创建 JAXB 类。
Click on Below Image Link For Details.
点击下方图片链接了解详情。
回答by Bruno Ranschaert
Put the tools.jar in the classpath of the projecct (where the generated code will reside).
将 tools.jar 放在项目的类路径中(生成的代码所在的位置)。
I found an explanation here https://bugs.eclipse.org/bugs/show_bug.cgi?id=345617It does not work because Eclipse only puts the JRE libraries in the classpath of the project. Since the xjc code is in tools.jar you need to provide this extra step.
我在这里找到了一个解释https://bugs.eclipse.org/bugs/show_bug.cgi?id=345617它不起作用,因为 Eclipse 只将 JRE 库放在项目的类路径中。由于 xjc 代码在 tools.jar 中,因此您需要提供这个额外的步骤。
回答by You_Shall_Not_Pass
Download com.springsource.com.sun.tools.xjc-2.1.7.jar
下载 com.springsource.com.sun.tools.xjc-2.1.7.jar
and configure the build path. This solved the warning and the error for me. Hope this helps.
并配置构建路径。这为我解决了警告和错误。希望这可以帮助。