代码之家  ›  专栏  ›  技术社区  ›  John Eipe

Maven多模块构建问题

  •  0
  • John Eipe  · 技术社区  · 6 年前

    我试图让这个示例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
    

    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] 
    

    天气网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 回复  |  直到 6 年前
        1
  •  0
  •   Mohit Sharma    6 年前

    依赖项包含中的问题。我获取了你的github代码并更改了持久性pom。

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

    siruscom换成了siriuscom,效果很不错,

    总是复制粘贴,从不手动键入。