首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用Maven Cargo部署多模块项目

使用Maven Cargo部署多模块项目
EN

Stack Overflow用户
提问于 2012-02-21 21:19:25
回答 1查看 2.6K关注 0票数 1

在我正在处理的这个项目中,我有一个很大的主pom文件,它定义了几个模块(domain、dao、service、war)。

我想使用Cargo将war部署到我的远程tomcat服务器上。

但是,运行mvn cargo:deploy -Ptest会出现一个错误,即无法解析模块道中模块域的依赖关系。

我试过在war pom中设置货物配置,但仍然是一样的。

有人能帮我吗?

这是父POM

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.domain</groupId>
    <artifactId>product</artifactId>
    <version>1.2-SNAPSHOT</version>
    <packaging>pom</packaging>

    <dependencyManagement>
        <dependencies>
            <!-- Internal dependencies -->
            <dependency>
                <groupId>com.domain.product</groupId>
                <artifactId>product-domain</artifactId>
                <version>${project.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.domain.product.dao</groupId>
                <artifactId>product-dao-api</artifactId>
                <version>${project.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.domain.product.dao</groupId>
                <artifactId>product-dao-jpa2</artifactId>
                <version>${project.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.domain.product.service</groupId>
                <artifactId>product-service-api</artifactId>
                <version>${project.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.domain.product.service</groupId>
                <artifactId>product-service-impl</artifactId>
                <version>${project.version}</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.domain.product</groupId>
                <artifactId>product-war</artifactId>
                <version>${project.version}</version>
                <type>jar</type>
                <type>war</type>
                <scope>compile</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.cargo</groupId>
                    <artifactId>cargo-maven2-plugin</artifactId>
                    <version>1.2.0</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <!-- profiles -->
    <profiles>
        <profile>
            <id>test</id>
            <activation>
            <property>
                <name>environment.type</name>
                <value>test</value>
            </property>
            </activation>
            <properties>
            </properties>
        </profile>
    </profiles>

    <modules>
        <module>product-domain</module>
        <module>product-dao-api</module>
        <module>product-dao-jpa2</module>
        <module>product-service-api</module>
        <module>product-service-impl</module>
        <module>product-war</module>
    </modules>
</project>

这是WAR POM:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>product</artifactId>
        <groupId>com.domain</groupId>
        <version>1.2-SNAPSHOT</version>
    </parent>
    <groupId>com.domain.product</groupId>
    <artifactId>product-war</artifactId>
    <name>product</name>
    <packaging>war</packaging>

    <dependencies>
        <dependency>
            <groupId>com.domain.product.service</groupId>
            <artifactId>product-service-impl</artifactId>
        </dependency>
        <dependency>
            <groupId>com.domain.product.service</groupId>
            <artifactId>product-service-api</artifactId>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>test</id>
            <activation>
                <property>
                    <name>environment.type</name>
                    <value>test</value>
                </property>
            </activation>
            <properties>
                <!-- Deployment settings -->
                <cargo.containerId>tomcat7x</cargo.containerId>
                <cargo.baseurl>http://test.domain.net:8080</cargo.baseurl>
                <container.url>${cargo.baseurl}/manager/text</container.url>
                <container.user>tomcat-txt</container.user>
                <container.password>password</container.password>
                <container.pingurl>${cargo.baseurl}/${project.name}/index.html</container.pingurl>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                        <configuration>
                            <wait>true</wait>
                            <container>
                                <containerId>${cargo.containerId}</containerId>
                                <type>remote</type>
                            </container>
                            <configuration>
                                <type>runtime</type>
                                <properties>
                                    <cargo.remote.uri>${container.url}</cargo.remote.uri>
                                    <cargo.remote.username>${container.user}</cargo.remote.username>
                                    <cargo.remote.password>${container.password}</cargo.remote.password>
                                </properties>
                            </configuration>
                            <deployer>
                                <deployables>
                                    <deployable>
                                        <groupId>com.domain.product</groupId>
                                        <artifactId>product-war</artifactId>
                                        <type>war</type>
                                        <properties>
                                            <context>${project.name}</context>
                                        </properties>
                                        <pingURL>${container.pingurl}</pingURL>
                                    </deployable>
                                </deployables>
                            </deployer>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

正如您所看到的,war依赖于服务,而服务本身又依赖于dao和域。

EN

回答 1

Stack Overflow用户

发布于 2012-03-15 03:23:51

在我看来,您必须首先使用mvn安装,然后

代码语言:javascript
运行
复制
mvn -pl product-war cargo:deploy -Ptest
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9378329

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档