简体   繁体   English

如何在Hudson中构建蚀动态Web项目

[英]how to build an eclipse dynamic web project in hudson

I have been using maven projects in hudson quite successfully for some time. 我已经在Hudson上成功使用了Maven项目已有一段时间了。 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. 但是这一次我需要构建一个通常在eclipse中构建的Eclipse动态Web项目,然后将战争导出到生产中。 How can I build this project in hudson. 我如何在哈德逊市建立这个项目。

Thanks in advance! 提前致谢!

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. 如果您熟悉Maven,建议您使用m2e-wtp插件-这样,您就可以将Maven和WTP都用于Web应用程序。 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. 现在m2e已移至Eclipse Foundation,应该在m2e目录中的某个位置(“窗口”>“首选项”>“ Maven”)中, 在Eclipse Indigo / 3.7中检查Maven / Tomcat项目

  • Hudson/Jenkins will just build it as a regular Maven project, no extra config needed. Hudson / Jenkins只会将其构建为常规的Maven项目,而无需额外的配置。
  • Eclipse will mostly continue to use its own tools with some Maven inbetween, but most importantly it will get any dependenices from Maven and have them in the build path Eclipse将继续在其间的一些Maven中继续使用其自己的工具,但最重要的是它将从Maven获取任何依赖关系并将其放入构建路径中

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: 如果您在Eclipse中已经有一个Dynamic Web Project,则可能必须四处移动文件夹以按照Maven期望的结构来排列它们:

src/
    main/
        java/        -- your Java source files (servlets, actions, ...)
        resources/   -- your resource files (struts.xml, log4j.xml, NOT web.xml)
        webapp/      -- your web root (previously WTP's WebContent/)
            WEB-INF/ -- your WEB-INFt (web.xml)
    test/
        java/        -- your Java test cases
        resources/   -- your test resource files
pom.xml

Set the <packaging> to war so Maven knows that it should put your dependencies into WEB-INF/lib/ and build a WAR. <packaging>设置为war以便Maven知道应该将您的依赖项放入WEB-INF/lib/并构建WAR。

As for dependenices, you'll probably need the Servlet API: 至于依赖关系,您可能需要Servlet API:

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>servlet-api</artifactId>
  <version>2.5</version><!-- change version as needed -->
  <scope>provided</scope><!-- Mind the scope!-->
</dependency>

Pay attentation to the provided scope: The Servlet spec prohibits web apps to bring their own Servlet API JAR along in WEB-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). 注意所provided范围:Servlet规范禁止Web应用程序将其自己的Servlet API JAR引入WEB-INF/lib并且在这种情况下,合格的Web容器将拒绝加载您的Web应用程序(它们将在他们支持的版本)。

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). 最好首先右键单击Dynamic Web Project,然后转到Maven> Convert to Maven项目,然后移动如上所示的文件夹,然后仔细检查m2e和m2e-wtp插件向您发出的所有警告(大多数快速修复)。

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

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