在java webapp / client中管理Web服务/ xml绑定的生成工件的最佳方式? [英] Best ways to manage generated artifacts for web service/xml bindings in a java webapp/client?

查看:106
本文介绍了在java webapp / client中管理Web服务/ xml绑定的生成工件的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一些使用JAXB绑定的Web服务(在JAX-WS或spring-ws中)。当使用这些绑定时,总会有一些代码是从WSDL自动生成的,用于绑定消息对象。我正在努力找出我可以使这项工作的最佳方式,以便易于使用,很难打破并与IDE完美集成(大多使用eclipse)。



<我认为有几种方法可以解决这个问题。我现在看到的三个主要选项是:




  • 生成代码,保留源代码,并将它们检入存储库。优点:易于与IDE集成(源突出显示等),在构建系统中工作。缺点:每次重新生成代码时都会发生变化,可能会导致嘈杂的提交。通常情况下,WSDL文件已被签入,因此也是多余的。

  • 生成代码作为构建过程的一部分。不要保留源文件或仅将其保存在输出目录中。优点:修复前一个的所有缺点。缺点:与IDE集成更难,虽然这个构建步骤可以自动运行吗?我目前在我的一个项目中使用这个项目,但是我第一次检出项目看起来是坏的,这是一个小小的麻烦。

  • 将生成的绑定保存在包含在maven中的单独的库(jar)中或手动更新的jar,具体取决于您的构建过程。我得到了 java.net上的一个线程的想法。这看起来比较稳定,使用了明确的版本控制,但似乎有点重。



您将执行哪些选项?我们正在使用maven和eclipse,所以在这方面的任何想法都会很棒。我认为这个问题可以推广到大多数其他的构建系统和IDE组合,甚至还有其他语言。

解决方案

我会去选项2,并在构建过程的一部分中生成标准 $ {project.build.directory} / generated-sources /< toolname> 位置中的代码。使用生成的源是m2eclipse(使用 Maven>更新项目配置一旦生成源代码),并且如果我记得很好,由 maven eclipse插件(即文件夹将被添加到 Java构建路径)。其实我觉得 NetBeans 也处理这个罚款。不确定Idea。



对于本身,您可能需要 maven-jaxb2-plugin 如果我理解正确。


I'm working on a couple of web services that use JAXB bindings for the messages (in JAX-WS or spring-ws). When using these bindings there's always some code that is automatically generated from the WSDL to bind the message objects. I'm struggling to figure out the best way I can make this work so that it's easy to work with, hard to break and integrates nicely with IDEs (mostly using eclipse).

I think there are a couple of ways to go about this. The three main options I see right now are:

  • Generate code, keep the source artifacts and check them into the repository. Pros: integrates easily with IDEs (source highlighting etc), works within the build system. Cons: generated code changes each time you regenerate it, possibly creating noisy commits. It's also redundant since the WSDL file is already checked in, usually.
  • Generate code as part of the build process. Don't keep source artifacts or only keep them in output directories. Pros: fixes all the cons from the previous one. Cons: harder to integrate with IDE, though maybe this build step can be run automatically? I currently use this on one of my projects but the first time I checkout the project it appears broken, which is a minor nuisance.
  • Keep generated bindings in separate libraries (jars) included with maven or manually updated jars, depending on your build process. I got the idea from a thread on java.net. This seems more stable and uses explicit versioning but seems a bit heavyweight.

Which one of these options would you implement and how? We're currently using maven and eclipse, so any ideas in that regard would be great. I think this problem generalises to most other build systems and IDE combinations though, even other languages perhaps.

解决方案

I'd go for option 2 and generate code in the "standard" ${project.build.directory}/generated-sources/<toolname> location as part of the build process. Using generated sources is well supported by m2eclipse (use Maven > Update Project Configuration once sources have been generated) and, if I remember well, by the maven eclipse plugin as well (i.e. the folder will be added to the Java Build Path). Actually, I think NetBeans also handle this fine. Not sure for Idea.

For the generation itself, you may need the maven-jaxb2-plugin if I understood correctly.

这篇关于在java webapp / client中管理Web服务/ xml绑定的生成工件的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆