如何在 Hudson 中构建 Eclipse 动态 Web 项目
我在 hudson 中使用 Maven 项目已经相当成功一段时间了。 然而这次我需要构建一个 Eclipse 动态 Web 项目,该项目通常在 Eclipse 中构建,然后将 war 导出到生产环境。我怎样才能在哈德逊建立这个项目?
提前致谢!
I have been using maven projects in hudson quite successfully for some time.
However this time I need to build an eclipse dynamic web project that is usually built within eclipse and then the war is exported to production. How can I build this project in hudson.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您熟悉 Maven,我建议您使用
m2e-wtp
插件——这样您就可以在您的 Web 应用程序中同时使用 Maven 和 WTP。既然 m2e 已移至 Eclipse Foundation,它应该位于 m2e 目录中的某个位置(Window > Preferences > Maven),请检查 Eclipse Indigo/3.7 中的 Maven/Tomcat 项目 了解更多信息。如果您在 Eclipse 中已经有一个动态 Web 项目,您可能需要四处走动一堆文件夹,将它们排列在 Maven 期望的结构中:
将
设置为war
,以便 Maven 知道它应该将您的依赖项放入WEB-INF/lib/
并构建一个 WAR。至于依赖项,您可能需要 Servlet API:
注意
provided
范围:Servlet 规范禁止 Web 应用程序在WEB-INF/lib 中携带自己的 Servlet API JAR在这种情况下,符合标准的 Web 容器将拒绝加载您的 Web 应用程序(它们会以它们支持的版本自行提供 JAR)。
最好首先右键单击 Dynamic Web Project 并转到 Maven > 。转换为 Maven 项目,然后如上所示移动文件夹,然后检查 m2e 和 m2e-wtp 插件向您抛出的所有警告(大多数都提供快速修复)。
If you're familiar with Maven, I suggest you use the
m2e-wtp
plugin -- that way you can use both Maven and WTP for your web app. It should be somehwhere in the m2e catalogue (Window > Preferences > Maven) now that m2e moved to the Eclipse Foundation, check Maven/Tomcat Projects In Eclipse Indigo/3.7 for more.If you already have a Dynamic Web Project in Eclipse, you'll probably have to move around a bunch of folders to arrange them in the structure Maven expects:
Set the
<packaging>
towar
so Maven knows that it should put your dependencies intoWEB-INF/lib/
and build a WAR.As for dependenices, you'll probably need the Servlet API:
Pay attentation to the
provided
scope: The Servlet spec prohibits web apps to bring their own Servlet API JAR along inWEB-INF/lib
and conforming web containers will refuse to load your web app in that case (they will provide the JAR themselves in the version they support).It's probably best to start by right-clicking on the Dynamic Web Project and go Maven > Convert to Maven project, then move the folders as shown above and then go through all the warnings the m2e and m2e-wtp plugins throw at you (most offer a quickfix).