org.apache.maven.plugins 目标执行失败

问题描述 投票:0回答:2

我正在尝试使用 Maven 生成一个 war 文件,但出现此错误(省略了大部分下载日志输出以使日志更清晰):

Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-war-plugin/2.1.1/maven-war-plugin-2.1.1.pom
Downloaded: 
...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building tn.talan.selenium Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ tn.talan.selenium ---
...
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ tn.talan.selenium ---
...
[INFO] --- maven-war-plugin:2.1.1:war (default-cli) @ tn.talan.selenium ---
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-archiver/2.4.1/maven-archiver-2.4.1.pom
Downloaded: 
...
[INFO] BUILD FAILURE
...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-cli) on project tn.talan.selenium: Execution default-cli of goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war failed: Plugin org.apache.maven.plugins:maven-war-plugin:2.1.1 or one of its dependencies could not be resolved: Could not transfer artifact org.codehaus.plexus:plexus-io:jar:1.0.1 from/to central (http://repo.maven.apache.org/maven2): GET request of: org/codehaus/plexus/plexus-io/1.0.1/plexus-io-1.0.1.jar from central failed: Read timed out -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
...

这是我的 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/maven-
 v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>selenium</groupId>
  <artifactId>tn.talan.selenium</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>tn.talan.selenium Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <finalName>tn.talan.selenium</finalName>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <version>1.0-beta-1</version>
      </plugin>

    </plugins>

  </build>

</project>

我的 pom 有什么问题?有什么想法吗?

maven maven-plugin
2个回答
25
投票

maven-war-plugin
指定版本,例如

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.2</version>
</plugin>

2
投票

解决这个错误,什么都不用做,只需要更改你的jdk版本即可。您可以选择任何 jdk 版本,但不要选择最新版本。请尝试使用旧版本。推荐:JDK 11.0.11

© www.soinside.com 2019 - 2024. All rights reserved.