有谁知道如何配置 Maven 目标以在构建运行后部署到 tomcat 服务器?我知道使用 maven-tomcat-plugin 是可能的,但看起来这只适用于 Maven 2,而我使用的是 Maven 1.1
我目前正在尝试设置 Hudson,所以这将是我持续集成的一部分我希望像这样运行的阶段:
- 构建所有必要的组件
- 构建战争并部署到(本地)服务器
- 运行硒测试
对此的任何帮助将不胜感激。
谢谢。
does anyone know a way to configure a maven goal to deploy to a tomcat server after a build is run? I know that this is possible using the maven-tomcat-plugin but it looks as though as this only works for Maven 2 whereas I'm using Maven 1.1
I'm currently trying to set up Hudson so this would be part of my continuous intergration phase which I hope will run like this:
- Build all necessary components
- Build war and deploy to (local) server
- Run selenium tests
Any help with this would be much appreciated.
Thanks.
发布评论
评论(4)
老实说,我会重构您的项目以使用 Maven 2,有几个指南可以帮助减轻迁移痛苦(google maven 2 迁移),甚至还有 maven-one-plugin 来转换您的project.xml 或将您的Maven 1 插件打包为Maven 2。
如果您做不到这一点,您可以使用 Maven 1 ant插件 打包后将war复制到tomcat的webapps目录下。 Tomcat 将检测到新的战争并应对其进行热部署。
Honestly I would refactor your project to use Maven 2, there are several guides that can help ease migration pain (google maven 2 migration), and there is even the maven-one-plugin to convert your project.xml or package your Maven 1 plugins for Maven 2.
If you can't do that, you could use the Maven 1 ant plugin to copy the war to tomcat's webapps directory after it has been packaged. Tomcat will detect the new war and should hot-deploy it.
我必须承认,我对 Maven 插件了解不多,但我在一个简单的脚本中完成了所有操作,该脚本也清理了工作目录(不知道 Maven 插件是否清理了工作目录)。
(我知道,-1 表示 MS 脚本)
重点是您通常想要清理工作目录和 webapps 目录,而 Maven 1 ant 插件不会执行此操作(据我所知,并从提供的链接中读取) 。当 Tomcat 分解 war 文件时,“应该”在这些目录中重新创建类文件,但任何长期使用它的人都知道:情况并非总是如此。
因此,如果插件不清理这些目录,就我而言它是没有用的。给自己写一个像提供的那样的廉价小脚本。需要 2 分钟。
I have to admit, I don't know much about the plugin for maven, but I do everything in a simple script that cleans the work directories as well (don't know if the maven plugin cleans the work directories).
(I know, -1 for MS scripting)
The point is you generally want to clean the work directory and the webapps directory and the Maven 1 ant plugin does not do this (as far as I know if, and read from the link provided). Tomcat is "supposed" to recreate the class files in these directories when it explodes the war file, but anybody who has worked with it long enough knows: this isn't always the case.
Therefore, if the plugin does not clean these directories, it's useless as far as I am concerned. Write yourself a cheap little script like the one provided. It takes 2 minutes.
我已经找到了最好的方法来做到这一点 - 实际上编写一个专家目标来转移战争非常容易。目标可以写成如下:
服务器变量可以在您的project.properties 文件中确定。另外,请确保在尝试部署 WAR 之前指定构建 WAR 的先决条件。希望这对某人有帮助!
I've figured out that best way to do this - its actually pretty easy to write a maven goal to transfer the war. The goal could be written as follows:
The server variable can be determined in your project.properties file. Also be sure to specify that a pre-requisite to build the WAR before you try to deploy it. Hope this helps someone!
可以为maven-war-plugin配置webapp目录来部署爆炸战争。不需要什么特别的,只需运行 maven install 即可。
webappDirectory can be configured for maven-war-plugin to deploy exploded war. Nothing special is needed, just run maven install.