首页 > 解决方案 > Maven 包装器生命周期失败

问题描述

当我尝试使用 Intellij 的终端进行 Maven 构建时,我遇到了错误。

只是不确定要做什么或问题是什么。相同的配置适用于早期的 springboot 项目。

错误信息:

D:\springboot\api\streetapiservice>mvnw clean install
The system cannot find the path specified.
'B' is not recognized as an internal or external command,
operable program or batch file.
The directory name is invalid.
Exception calling "DownloadFile" with "2" argument(s): "An exception occurred during a WebClient request."
At line:1 char:282
+ ... pe]::Tls12; $webclient.DownloadFile('https://repo.maven.apache.org/ma ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException
 
Error: Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain

POM 文件 下面是 pom 文件——我已经删除了一些依赖项。这是使用 spring starter 创建的。

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.api</groupId>
    <artifactId>streetapiservice</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>streetapiservice</name>
    <description>Api for handling calls street api</description>

    <properties>
        <java.version>1.8</java.version>
        <sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version>
        <mock-sever-netty-version>3.10.8</mock-sever-netty-version>
        <apache-http-version>4.4.1</apache-http-version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
            </plugin>
            
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.platform</groupId>
                        <artifactId>junit-platform-surefire-provider</artifactId>
                        <version>1.0.1</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.9</version>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

标签: javaspring-bootmavenpom.xml

解决方案


  • 当我尝试通过 git bash 运行相同的代码时,它运行良好。
  • 问题似乎与 IDE 有关
  • 重新导入项目解决了这个问题

推荐阅读