Maven多模块构建问题

时间:2018-10-24 05:21:10

标签: java maven

我正在尝试从Maven本书中获取此示例Maven多模块项目以进行构建和安装,但它说从属兄弟姐妹不可用。

enter image description here

我首先尝试编译并安装天气模型,它运行正常。

[INFO] Installing /Users/johne/IdeaProjects/WeatherApp/weather-web/weather-model/target/weather-model-1.0-SNAPSHOT.jar to /Users/johne/.m2/repository/com/testcom/weather-model/1.0-SNAPSHOT/weather-model-1.0-SNAPSHOT.jar
[INFO] Installing /Users/johne/IdeaProjects/WeatherApp/weather-web/weather-model/pom.xml to /Users/johne/.m2/repository/com/testcom/weather-model/1.0-SNAPSHOT/weather-model-1.0-SNAPSHOT.pom

但是,当我从weather-web目录尝试mvn install时,它会失败。

[WARNING] The POM for com.testcom:weather-model:jar:1.0-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Weather Web POM .................................... SUCCESS [  9.215 s]
[INFO] Weather App Model .................................. SUCCESS [  0.564 s]
[INFO] Weather App Persistence ............................ FAILURE [  0.028 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.933 s
[INFO] Finished at: 2018-10-24T10:48:28+05:30
[INFO] Final Memory: 15M/208M
[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal on project weather-persist: Could not resolve dependencies for project com.testcom:weather-persist:jar:1.0-SNAPSHOT: Could not find artifact com.testcom:weather-model:jar:1.0-SNAPSHOT -> [Help 1]
[ERROR] 

WeatherWeb pom.xml

<?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/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>weatherapp</artifactId>
        <groupId>com.testcom</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>weather-web</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>


    <modules>
        <module>weather-model</module>
        <module>weather-persist</module>
    </modules>

    <name>Weather Web POM</name>


    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

天气持久性pom.xml

<?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/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>weather-web</artifactId>
        <groupId>com.testcom</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>weather-persist</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>

    <name>Weather App Persistence</name>

    <dependencies>
        <dependency>
            <groupId>com.testcom</groupId>
            <artifactId>weather-model</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate</artifactId>
            <version>3.2.5.ga</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.transaction</groupId>
                    <artifactId>jta</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.3.0.ga</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>3.3.0.ga</version>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-jta_1.1_spec</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>2.0.7</version>
        </dependency>
    </dependencies>
</project>

天气模型pom.xml

<?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/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>weather-web</artifactId>
        <groupId>com.testcom</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>weather-model</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Weather App Model</name>
    <dependencies>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.3.0.ga</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate</artifactId>
            <version>3.2.5.ga</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.transaction</groupId>
                    <artifactId>jta</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

</project>

1 个答案:

答案 0 :(得分:0)

包含依赖项中的问题。我接受了您的github代码并更改了持久性pom。

   <dependency>
        <groupId>com.siriuscom</groupId>
        <artifactId>weather-model</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

siruscom更改为siriuscom,它的工作原理就像一个魅力, 在您发布不同组ID的问题中,它也有效。

始终复制粘贴,从不手动键入。