如何将 JAXB 生成的源代码放到 m2e/Indigo 下的 Eclipse 构建路径上?
在 Helios/m2eclipse 下,当我生成 jaxb 源时,当我执行“更新项目配置”时,它们将被放置在 Eclipse 源路径中。
Indigo/m2e(2011 年 6 月 22 日首次发布)不会发生这种情况。我需要做什么来解决这个问题?
我正在使用标准的 maven-jaxb2-plugin,版本 0.75。
Under Helios/m2eclipse, when I generated jaxb sources they would be put on the Eclipse source path when I did an "Update Project Configuration".
This doesn't happen with Indigo/m2e (initial release of 22 June 2011). What do I need to do to fix this?
I'm using the standard maven-jaxb2-plugin, version 0.75.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在 Eclipse 中,转到“安装新软件”,添加软件站点:http://bitstrings。 github.com/m2e-connectors-p2/releases/
选择“用于 jaxb2 的 m2e 连接器”
安装该插件后,jaxb2 插件应该与新版本的 m2e 正确集成。
此信息来自:https://bugs.eclipse.org/bugs/show_bug。 cgi?id=350299
In Eclipse go to "Install New Software" add the software site: http://bitstrings.github.com/m2e-connectors-p2/releases/
Select the "m2e connector for jaxb2"
Once you get that plugin installed the jaxb2 plugin should integrate correctly with the new version of m2e.
This info is from: https://bugs.eclipse.org/bugs/show_bug.cgi?id=350299
好吧,您需要右键单击“target/ generated-sources/xjc 并选择类似“Build Path ->用作源文件夹”
Well, you need to right click on the "target/generated-sources/xjc and select something like "Build Path -> Use as source folder"
作为替代解决方法,如果您无法使 m2e 连接器正常工作,您可以使用 build-helper-maven-plugin 将生成的源添加到构建路径:
As an alternate workaround if you can't get the m2e connector working, you can add the generated sources to the build path with build-helper-maven-plugin:
在等待此问题的修复时,我使用以下临时解决方法:
我们在单独的 Maven 模块中拥有 jaxb-plugin 和生成的类。在 Eclipse 中,我只能在该模块上“禁用 Maven 性质”。然后我可以在大型 Maven 项目的其余部分上使用 Indigo 和 m2eclipse,它将依赖于 jaxb 模块的 jar(必须从命令行构建)。这对我来说很有效,因为我们的项目已经以这种方式组织了。
While waiting for a fix for this problem, I'm using the following temporary workaround:
We have the jaxb-plugin and generated classes in a separate maven module. In eclipse I can then "disable Maven nature" on that module only. Then I can use Indigo with m2eclipse on the rest of our large maven project and it will depend on the jar for the jaxb module (must be built from the command line). This works well for me since our project was allready organized this way.
对于那些遭受 maven-jaxb2-plugin 和 Eclipse 未附加源代码困扰的人。作者已从 Sun 切换到Glassfish JAXB 工件 和依赖关系树已更改。以前,许多 JAR 都被隐藏到
jaxb-xjc
中,而没有传递 JAR。现在,它已被删除,之前对tools.jar
的传递依赖会破坏 Eclipse 的执行。使用 JDK VM 启动 Eclipse,它将正常工作。 (测试了最新的 Maven 3.3.9、Maven JAXB2 插件 0.13.1、最新的 m2e JAXB2 连接器和 Eclipse Mars.2)For those who are suffering with maven-jaxb2-plugin and Eclipse not having source attached. The author has switched from the Sun to the Glassfish JAXB artifacts and the dependency tree has changed. Previously many JARs where shaded into
jaxb-xjc
without transitive ones. Now, this has been removed and the previous transitive dependency totools.jar
breaks Eclipse execution. Start your Eclipse with a JDK VM and it will work. (Tested most recent Maven 3.3.9, Maven JAXB2 Plugin 0.13.1, recent m2e JAXB2 connector and Eclipse Mars.2)