我有一個開發的應用程序,我只是試圖使構建過程容易。父母的POM文件如下所示:如何部署一個特定的子項目與貨物:開始使用maven
<parent>
<groupId>com.shc.obu.ca</groupId>
<artifactId>shcobuca-pom</artifactId>
<version>1.1.0</version> </parent>
<groupId>com.shc.obu.ca.osol</groupId> <artifactId>apps-pom</artifactId> <version>${currVersion}</version> <packaging>pom</packaging> <name>Outlet Apps</name>
<scm>
<connection>scm:svn:https://ushofsvpsvn2.intra.searshc.com/svn/outlet/outlet/trunk/apps</connection>
<developerConnection>scm:svn:https://ushofsvpsvn2.intra.searshc.com/svn/outlet/outlet/trunk/apps</developerConnection> </scm>
<profiles>
<profile> <id>www</id>
<activation> <activeByDefault>true</activeByDefault> </activation>
<modules>
<module>www</module>
<module>modules</module>
</modules>
</profile>
<profile>
<id>mts</id>
<activation> <activeByDefault>true</activeByDefault> </activation>
<modules>
<module>mts</module>
<module>modules</module>
</modules>
</profile>
<profile> <id>search</id>
<activation> <activeByDefault>true</activeByDefault> </activation>
<modules>
<module>modules</module>
<module>search</module>
</modules>
</profile> </profiles>
<repositories>
<repository>
<id>obu.ca.repo.release</id>
<snapshots><enabled>false</enabled></snapshots>
<url>http://maven.cal.intra.sears.com/release</url>
</repository>
<repository>
<id>obu.ca.repo.snapshot</id>
<releases><enabled>false</enabled></releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>interval:5</updatePolicy>
</snapshots>
<url>http://maven.cal.intra.sears.com/snapshot</url>
</repository> </repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<env>trunk</env>
<currVersion>1.2.0</currVersion> </properties> </project>
此文件顯示它具有三個基本上獨立的子項目的配置文件。我加入的貨物插件如下文件:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<home>
C:\tools\apache-tomcat-6.0.26
</home>
</container>
<configuration>
<properties>
<cargo.servlet.port>
8082
</cargo.servlet.port>
<cargo.jvmargs>
"-Xdebug" "-Xrunjdwp:transport=dt_socket,address=4646,server=y,suspend=n"
</cargo.jvmargs>
</properties>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
但是當我運行「命令mvn貨物:啓動」,Tomcat實例運行良好,但沒有孩子的應用程序得到部署。有沒有辦法讓我的第一個子應用程序(www)(它生成一個名爲www-webapp-1.2.0.war的war文件)自動部署?
更新:感謝帕斯卡。我試圖修改構建標籤如下:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<home>
C:\tools\apache-tomcat-6.0.26
</home>
</container>
<configuration>
<properties>
<cargo.servlet.port>
8082
</cargo.servlet.port>
<cargo.jvmargs>
"-Xdebug" "-Xrunjdwp:transport=dt_socket,address=4646,server=y,suspend=n"
</cargo.jvmargs>
</properties>
<deployables>
<deployable>
<groupId>com.shc.obu.ca.osol</groupId>
<artifactId>www-webapp-1.2.0</artifactId>
<type>war</type>
<properties>
<context>acontext</context>
</properties>
</deployable>
</deployables>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
但仍然不工作。它的構建錯誤如下:
工件[com.shc.obu.ca.osol:www-webapp-1.2.0:war]不是項目的依賴項。 我嘗試了'www-webapp'和'www'作爲工件ID,但錯誤仍然保持不變。
當我添加相同的產生依賴性的標籤,它提供了某種如下循環引用錯誤的: 「在反應器中的項目包含一個循環引用」
帕斯卡爾嗨, 能否請你幫我帶兩個其中U建議使用上面提供的POM代碼的方法的樣本。我嘗試了第一種方法,然後得到一些錯誤,比如插件標籤不能識別配置文件等,不知道如何實現第二種方法。 謝謝, Neeraj – Neeraj 2010-07-06 15:26:28
@Neeraj:這表明POM無效。在配置文件中,插件應在' ... '中聲明。 –
2010-07-06 17:08:36
POM是有效的,我可以將整個構建標籤移動到www profile中,但結果是一樣的。我嘗試了'mvn cargo:start'和'mvn -Pwww貨物:開始',但我的應用程序www-webapp-1.2.0.war仍未部署或啓動。 但是,如果我嘗試運行'mvn -Pwww cargo:deploy'命令(在配置文件外部或內部使用構建標記),我的'www'war文件(www-webapp-1.2.0.war)確實會將副本發送到webapps貨物下的文件夾。 – Neeraj 2010-07-07 11:35:17