0

我正在尝试运行mvn clean install(在 Windows 上),但出现以下错误:

    [ERROR] Plugin org.apache.maven.plugins:maven-compiler-plugin:3.2.3 or one of its dependencies could not be resolved: Failure to find 
org.apache.maven.plugins:maven-compiler-plugin:jar:3.2.3 in http://dist.wso2.org
/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of wso2-maven2-repository-1 has elapsed or updates are forced -> [Help 1]

    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

由于这是我与 maven 合作的第一个项目,我不知道如何解决这个问题......

谢谢!

4

1 回答 1

3

检查 .m2/repository/org/apache/maven/plugins/maven-compiler-plugin/3.2.3 目录中的存储库中是否没有 _maven.repositories 或 *.lastUpdated 文件。如果找到然后删除它们。
接下来,您应该在 pom.xml 文件和 settings.xml(在 /home/.m2 中)文件中删除对http://dist.wso2.org/maven2的引用,因为 maven 编译器插件版本 3.2.3 不在此存储库。
(Maven 中央存储库是http://repo1.maven.org/maven2/)。在那里我找到了编译器插件版本 3.2。它似乎是最新版本http://maven.apache.org/plugins/index.html
因此,如果您使用此存储库,请将 pom.xml 中的版本更改为 3.2。
完成运行后,您再次构建。

在 pom.xml 中,您可以在以下<pluginManagement>部分设置插件版本:

  <project>
    ...
    <build>
      ...
      <pluginManagement>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
          </plugin>
        </plugins>
       </pluginManagement>
     </build>
   </project>

下面是一个最小的 settings.xml 以开始使用 maven 中央存储库(使用您自己的更改 ${unsername} ):

<settings>
  <localRepository>C:\Users\${username}\.m2\repository</localRepository>
    <repositories>
      <repository>   
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
        </snapshots>  
        <id>central</id>
        <name>central repository</name>
        <url>http://repo1.maven.org/maven2</url>      
      </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <id>central</id>
          <name>central repository</name>
          <url>http://repo1.maven.org/maven2</url>
        </pluginRepository>
      </pluginRepositories>
    </settings>
于 2014-12-18T13:25:31.017 回答