【问题标题】:maven codehaus.mojo could not be resolvedmaven codehaus.mojo 无法解决
【发布时间】:2018-09-26 06:16:19
【问题描述】:

我正在尝试使用 NetBeans 构建一个 JavaFX 项目,但是当我运行它时,我有一个:

Plugin org.codehaus.mojo:exec-maven-plugin:1.2.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:exec-maven-plugin:jar:1.2.1: Could not transfer artifact org.codehaus.mojo:exec-maven-plugin:pom:1.2.1 from/to HTTP (http://repo.maven.apache.org/maven2): Access denied to: http://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-plugin/1.2.1/exec-maven-plugin-1.2.1.pom , ReasonPhrase:Forbidden. -> [Help 1]

我在代理后面工作,但我用我的代理配置了 Netbeans,我尝试了“测试连接”,这很有效。

我还用这个代理配置了“.m2/settings.xml”目录

<?xml  version="1.0" encoding="UTF-8"?> <settings>   <proxies>
    <proxy>
      <active />
      <protocol>http</protocol>
      <username>username</username>
      <password>password</password>
      <port>8080</port>
      <host>proxyhost</host>
      <id/>
    </proxy>   </proxies>
     <mirrors>
    <mirror>
      <id>HTTP</id>
      <name>HTTP Central</name>
      <url>http://repo.maven.apache.org/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>   </mirrors> </settings>

我的 pom.xml

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

    <groupId>com.bega</groupId>
    <artifactId>Chronos</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Chronos</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mainClass>com.bega.chronos.MainApp</mainClass>
    </properties>

    <organization>
        <!-- Used as the 'Vendor' for JNLP generation -->
        <name>Your Organisation</name>
    </organization>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <excludeScope>system</excludeScope>
                            <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
                            <outputDirectory>${project.build.directory}/classes</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>

                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${java.home}/../bin/javafxpackager</executable>
                            <arguments>
                                <argument>-createjar</argument>
                                <argument>-nocss2bin</argument>
                                <argument>-appclass</argument>
                                <argument>${mainClass}</argument>
                                <argument>-srcdir</argument>
                                <argument>${project.build.directory}/classes</argument>
                                <argument>-outdir</argument>
                                <argument>${project.build.directory}</argument>
                                <argument>-outfile</argument>
                                <argument>${project.build.finalName}.jar</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-cli</id>
                        <goals>
                            <goal>exec</goal>                            
                        </goals>
                        <configuration>
                            <executable>${java.home}/bin/java</executable>
                            <commandlineArgs>${runfx.args}</commandlineArgs>
                        </configuration>
                    </execution>
                </executions>  
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <additionalClasspathElements>
                        <additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement>
                    </additionalClasspathElements>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>de.jensd</groupId>
            <artifactId>fontawesomefx</artifactId>
            <version>8.9</version>
        </dependency>
    </dependencies>

</project>

如果有人知道为什么这不起作用?

【问题讨论】:

标签: netbeans maven-2 maven-plugin


【解决方案1】:

我假设存储库服务器暂时无法正常工作。至少我能够下载错误消息中提到的文件。

不幸的是,Maven 缓存了未找到的错误。 SO上有很多关于重置缓存状态和强制重新下载的问题。

恕我直言,最简单的方法是从本地 Maven 存储库中删除有问题的工件的所有数据,该存储库位于用户主目录的子目录 .m2/repository 中。

打开.m2/repository 并进入路径org/codehaus/mojo/exec-maven-plugin/。删除子目录1.2.1 和所有包含的文件。下次需要它们时,Maven 会自动下载它们。

【讨论】:

    【解决方案2】:

    有时只是同步

    只需点击按钮刷新即可解决问题

    【讨论】:

      【解决方案3】:

      转到本地 maven 存储库,删除 corespondent 文件夹。作为 D:\MAVENrepo\org\codehaus\mojo\exec-maven-plugin\1.2.1, 使用Alt+f5更新maven项目。

      【讨论】:

        【解决方案4】:

        打开C:\Users\your user\\.m2\repository\org\codehaus\mojo\exec-maven-plugin,删除子目录1.2.1,如果maven没有自动下载,可以使用这个命令:

        mvn dependency:purge-local-repository
        

        【讨论】:

          【解决方案5】:

          好吧,我遇到了同样的错误,所以我把它放在这里只是为了有人遇到同样的问题。使用 wagon-plugin:依赖版本获得了 2.0.0 的额外数字 我的版本设置为 2.0 并且弹出了这个错误(y ofc 还有什么 d'uh)

          <dependency>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>wagon-maven-plugin</artifactId>
              <version>**2.0.0**</version>
          </dependency>
          
          <dependency>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>wagon-maven-plugin</artifactId>
              <version>**1.0**</version>
          </dependency>
          

          为了将来的参考,他们可能会将 reponame 从 codehaus 更改为 mojohaus(现在仍然是旧的 reponame)。希望这对某人有帮助!

          【讨论】:

            【解决方案6】:

            从 netbeans 访问 https://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-plugin/1.2.1/exec-maven-plugin-1.2.1.pom 时构建失败

            我从浏览器访问了 url,然后它显示网络错误。 再次刷新 url 它加载了对浏览器的响应 我重建并运行它加载项目没有以前的问题

            似乎是来自 netbeans 的网络错误或网络代理故障。

            目前已解决

            【讨论】:

              【解决方案7】:

              对我来说,我等了几分钟,然后再次尝试了mvn package 命令,它成功了。由于某种原因,似乎偶尔会失败。

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 2017-01-06
                • 1970-01-01
                • 2012-01-12
                • 2010-12-29
                • 1970-01-01
                • 1970-01-01
                • 2011-12-08
                • 2014-12-19
                相关资源
                最近更新 更多