微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Maven 包装器生命周期失败

如何解决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>

解决方法

  • 当我尝试通过 git bash 运行相同的代码时,它运行良好。
  • 问题似乎出在 IDE 上
  • 重新导入项目修复了问题

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。