无法读取 org.apache.maven.plugins 的工件描述符:maven-resources-plugin:jar:3.0.5

Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:3.0.5

我想使用 spring boot and react js 构建一个网络应用程序(遵循教程 here)。 在 pom.xml 中我添加了:

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.0.5</version>
    <executions>
        <execution>
            <id>Copy frontend production build to resources</id>
            <phase>package</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${basedir}/target/classes</outputDirectory>
                <resources>
                    <resource>
                        <directory>src/main/app/build/</directory>
                        <filtering>true</filtering>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

执行 mvn clean package 时,出现以下错误。 Maven 版本是 3.0.5.

Plugin org.apache.maven.plugins:maven-resources-plugin:3.0.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:3.0.5: Failure to find org.apache.maven.plugins:maven-resources-plugin:pom:3.0.5 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced

编辑: 我已经将 maven-resources-plugin 标签中的 maven 版本更改为 3.0.2 但现在我收到错误消息:

<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>
    <version>1.2</version>
    <executions>
        <execution>
            <id>Install Node and Yarn</id>
            <goals>
                <goal>install-node-and-yarn</goal>
            </goals>
        </execution>

        <execution>
            <id>yarn install</id>
            <goals>
                <goal>yarn</goal>
            </goals>
            <configuration>
                <arguments>install</arguments>
            </configuration>
        </execution>

        <execution>
            <id>Frontend production build</id>
            <phase>package</phase>
            <goals>
                <goal>yarn</goal>
            </goals>
            <configuration>
                <arguments>run build</arguments>
            </configuration>
        </execution>
    </executions>
    <configuration>
        <nodeVersion>v7.2.0</nodeVersion>
        <yarnVersion>v0.18.0</yarnVersion>
        <installDirectory>.mvn</installDirectory>
        <workingDirectory>src/main/app</workingDirectory>
    </configuration>
</plugin>

错误:

[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.2:install-node-and-yarn (Install Node and Yarn) on project ema: The plugin com.github.eirslett:frontend-maven-plugin:1.2 requires Maven version 3.1.0 -> [Help 1]

简而言之,您的问题在这里:

<artifactId>maven-resources-plugin</artifactId>
<version>3.0.5</version>

这个版本是为了传达maven-resources-plugin的版本,而不是maven本身。

适用于此处的最新版本是 3.0.2

我还建议您将整个 Maven 安装升级到最新的 3.5.0 版本。

我遇到了同样的问题,然后我更改了代码 1.5。9.RELEASE 它现在可以正常工作

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

问题是您的 maven resource plugin repository 版本无效。

将您的 pom.xml 文件存储库更改为此。

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.0.2</version>
</dependency>