我正在使用以下文件夹结构:
SpringMvcExample
\_ pom.xml (root pom)
\_ parent
\_ pom.xml (parent pom)
\_ model
\_ src
\_ pom.xml (child pom)
以下是文件示例:
根.pom:
<groupId>com.pack</groupId>
<artifactId>SpringMvcExample</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>SpringMvcExample</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<defaultGoal>package</defaultGoal>
</build>
<modules>
<module>parent</module>
<module>model</module>
</modules>
父pom:
<modelVersion>4.0.0</modelVersion>
<groupId>com.pack</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.pack</groupId>
<artifactId>model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
型号:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.pack</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<groupId>com.pack</groupId>
<artifactId>model</artifactId>
<version>1.0-SNAPSHOT</version>
<name>model</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
当我尝试从模型文件夹调用 mvn clean install 时,出现以下错误:
[ERROR] Failed to execute goal on project model: Could not resolve dependencies for project com.pack:model:jar:1.0-SNAPSHOT: Could not find artifact com.pack:model:jar:1.0-SNAPSOT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project model: Could not resolve dependencies for project com.pack:model:jar:1.0-SNAPSHOT: Could not find artifact com.pack:model:jar:1.0-SNAPSHOT
我应该怎么做才能解决它?