创建一个新的包类型maven,并在tomcat项目中使用它



我创建了一个带有子模块的新父项目

  • OldParent
    • 儿童1===========>pom.xml
    • 儿童2===========>pom.xml
    • 库===========>pom.xml

    ======>pom.xml

======>pom.xml

我用一个新的扩展包".ria"创建了模块"Lib"参见以下pom.xml

<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">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>MyProjectId</groupId>
    <artifactId>Parent</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <artifactId>Lib</artifactId>
  <packaging>ria</packaging>
  <build>
    <plugins>
    <--------------------My archetype project ---------------->
      <plugin>
        <groupId>MyProjectGroupeId</groupId>
        <artifactId>xx-archetype</artifactId>
        <version>1.0.0</version>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>
    <dependencies>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>Child 1</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>Child 2</artifactId>
        <version>${project.version}</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">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>MyProjectGroupeId</groupId>
    <artifactId>OldParent</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </parent>
  <groupId>MyProjectId</groupId>
  <artifactId>Parent</artifactId>
  <packaging>pom</packaging>
  <name>Common service for business solution</name>
    <dependencyManagement>
        <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>Child 1</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>Child 2</artifactId>
            <version>${project.version}</version>
        </dependency>
     </dependencies>
   </dependencyManagement>
  <modules>
    <module>Child 1</module>
    <module>Child 2</module>
    <module>Lib</module>
  </modules>
</project>

我已经在我的tomcat项目中声明了Lib项目的依赖关系

<!-- Module dependencies  -->
    <dependency>
      <groupId>MyProjectId</groupId>
      <artifactId>Lib</artifactId>
      <version>${lib.version}</version>
      <type>ria</type>
    </dependency> 

我的Maven依赖项中有所有的依赖项Child1和Child2但是我在maven安装Tomcat项目时出现了这个错误:

[ERROR] Failed to execute goal on project xx-server: Could not resolve dependencies for project MyProjectGroupeId:xx-server:war:1.0.0-SNAPSHOT: Failed to collect dependencies at MyProjectId:Lib:ria:1.0.0-SNAPSHOT: Failed to read artifact descriptor for MyProjectId:Lib:ria:1.0.0-SNAPSHOT Could not find artifact MyProjectGroupeId:OldParent:pom:1.0.0-SNAPSHOT -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

在我看来,您没有在存储库中安装MyProjectId:Lib:ria:1.0.0-SNAPSHOT

请尝试此项目目录中的mvn install,然后重试。

还检查它是否存在于~/.m2/repository中。

最新更新