1

在我正在处理的这个项目中,我有一个大型的主 pom 文件,它定义了几个模块(域、dao、服务、战争)。

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

运行 mvn cargo:deploy -Ptest 但是给我一个错误,即模块 dao 中模块域的依赖关系无法解决。

我试过把货物配置放在战争 pom 中,但还是一样。

有人能帮我吗?

这是父 POM

<?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>

这是战争 POM:

<?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>

正如你所看到的,战争依赖于服务,服务本身依赖于道,而服务依赖于域。

4

1 回答 1

2

在我看来,你必须先使用 mvn install 然后

mvn -pl product-war cargo:deploy -Ptest
于 2012-03-14T19:23:50.937 回答