简体   繁体   English

在 Eclipse 中从 .xsd 模式生成 Java 类

[英]Generate Java Classes from .xsd schema in eclipse

I am trying to generate JavaClasses for an existing .xsd file.我正在尝试为现有的 .xsd 文件生成 JavaClasses。 From the command line I could already manage to do so.从命令行我已经可以做到了。

To acheive the same in eclipse I tried to rightclick on the .xsd > Generate > JAXB Classes... but in the next dialogue I get the Error:为了在 Eclipse 中实现相同的目标,我尝试右键单击 .xsd > Generate > JAXB Classes...但在下一个对话中我得到了错误:

" The classpath for this project does not appear to contain the necessary libraries to proceed with class generation." “该项目的类路径似乎不包含继续生成类所需的库。”

I found many answsers refering to using the correct JDK, but I have already set jdk1.8.0 as a preference.我发现很多答案都提到使用正确的 JDK,但我已经将 jdk1.8.0 设置为首选项。 (I use Eclipse Kepler) (我使用 Eclipse 开普勒)

I hope I provided all neccessary information and that anyone can help me fix this issue, Thanks in advance我希望我提供了所有必要的信息,并且任何人都可以帮助我解决这个问题,提前致谢

I got this to work by adding jaxb jar files to my project's classpath.我通过将 jaxb jar 文件添加到我的项目的类路径来实现这一点。 I included: jaxb-core-2.3.0.jar, jaxb-impl-2.3.0.jar, and jaxb-xjc-2.3.0.jar.我包括:jaxb-core-2.3.0.jar、jaxb-impl-2.3.0.jar 和 jaxb-xjc-2.3.0.jar。 The impl jar was only added when I started using a bindings file which required me to enable vendor extensions. impl jar 仅在我开始使用需要启用供应商扩展的绑定文件时添加。 Otherwise the core and xjc jars were all I needed.否则,我只需要 core 和 xjc jar。 I included links to where I got my jars in case you do not already have them我包含了我得到罐子的链接,以防你还没有它们

http://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-xjc/2.3.0 http://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-xjc/2.3.0

http://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-core/2.3.0 http://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-core/2.3.0

https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl/2.3.0 https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl/2.3.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM