Maven 错误:Artifact 不是项目的依赖项

SRK*_*ash 4 java maven

   [ERROR] Failed to execute goal org.apache.maven.plugins:maven-ear-
    plugin:2.6:generate-application-xml (default-generate-application-xml) 
    on project itaras-ear: Artifact[war:org.apache.maven.plugins:maven-war-
    plugin] is not a dependency of the project. 
Run Code Online (Sandbox Code Playgroud)

首先,我为我的应用程序构建了一个 WAR 文件。现在我正在构建我的 EAR 文件,该文件应该具有 WAR 作为依赖项。

当我收到上述错误消息时,我已经使用 m2e 插件运行了 ITARAS-EAR 模块。

模块 WAR 的 pom.xml 如下。

  <parent>
   <groupId>itaras</groupId>
   <artifactId>itaras</artifactId>
   <version>1.0-SNAPSHOT</version>
  </parent>
<groupId>itaras-war</groupId>
 <artifactId>itaras-war</artifactId>
 <packaging>war</packaging>
  <build>
<plugins>
  <plugin>            
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
   <configuration>
       <webXml>src\main\webapp\WEB-INF\web.xml</webXml>        
      </configuration>
     </plugin>
     </plugins>
       </build>
    </project>
Run Code Online (Sandbox Code Playgroud)

模块 EAR 的 pom.xml 在这里。

  <parent>
  <groupId>itaras</groupId>
  <artifactId>itaras</artifactId>
  <version>1.0-SNAPSHOT</version>
  </parent>
 <artifactId>itaras-ear</artifactId>
 <packaging>ear</packaging>
  <dependencies>
    <dependency>
        <groupId>itaras-war</groupId>
        <artifactId>itaras-war</artifactId>

        <type>war</type>
        <version>${project.version}</version>
    </dependency>

   </dependencies>
     <build>
     <plugins>
      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-ear-plugin</artifactId>
        <version>2.6</version>
        <configuration>
              <defaultLibBundleDir>lib</defaultLibBundleDir>
            <applicationXML>src/main/application/META-
        INF/application.xml</applicationXML>
         </configuration>
    </plugin>
     </plugins>
    </build>
    <groupId>itaras-ear</groupId>
     </project>
Run Code Online (Sandbox Code Playgroud)

提前致谢。如果我犯了根本错误,请纠正我:)

Ess*_*Boy 5

你的战争项目有 2 个 groupIds

<parent>
   <groupId>itaras</groupId>
   <artifactId>itaras</artifactId>
   <version>1.0-SNAPSHOT</version>
  </parent>
*** <groupId>itaras-war</groupId> ****
<artifactId>itaras-war</artifactId>
<packaging>war</packaging>
Run Code Online (Sandbox Code Playgroud)

删除 groupId 并允许它从父级中选择它的 groupId。仅指定来自父级的 artifactId、version 和 groupId。

那么你在你的耳朵项目中对战争的依赖是:

<dependencies>
  <dependency>
      <groupId>itaras</groupId>
      <artifactId>itaras-war</artifactId>
      <type>war</type>
      <version>${project.version}</version>
  </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)