无法传输工件mysql:mysql-connector-java:pom:5.1.38 from / to central(http://repo.maven.apache.org/maven2)

时间:2016-01-28 13:49:52

标签: mysql eclipse maven dependencies

我正在Maven项目中工作并尝试添加最新版本的mysql-connector-java / 5.1.38依赖项im pom.xml。但是我得到了ArtifactDescriptorException:无法读取mysql的工件描述符:mysql-connector-java并且maven dependecies文件夹中没有mysql-connector jar。我还添加了旧版本的mysql-connector-java / 5.1.10和mysql-connector-java / 5.1.36版本,它没有任何例外,工作正常。

pom.xml在最新版本的mysql-connector-java / 5.1.38

中存在以下问题
ArtifactDescriptorException: Failed to read artifact descriptor for mysql:mysql-connector-java:jar:5.1.38: ArtifactResolutionException: Failure to transfer mysql:mysql-connector-java:pom:5.1.38 from 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. Original error: Could not transfer artifact mysql:mysql-connector-java:pom:5.1.38 from/to central (http://repo.maven.apache.org/maven2): null to http://repo.maven.apache.org/maven2/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.pom

我的pom.xml看起来像

<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.java.spring</groupId>
  <artifactId>practice</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>practice</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.2.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>4.2.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.2.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.38</version>
    </dependency>
  </dependencies>
  <build>
    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.apache.maven.plugins
                                    </groupId>
                                    <artifactId>
                                        maven-compiler-plugin
                                    </artifactId>
                                    <versionRange>
                                        [2.3.2,)
                                    </versionRange>
                                    <goals>
                                        <goal>compile</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
  </build>
</project>

我还清理了我的项目一次并更新它但在添加依赖项后发生了同样的错误。 那么我该如何解决这个问题呢?

2 个答案:

答案 0 :(得分:0)

我已将坐标添加到计算机项目中的pom.xml中。它奏效了。

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.38</version>
</dependency>

我写在这里,可能的解决方案。

1.如果您只是将maven坐标复制并粘贴到pom.xml,有时候,在空白处会有一些不可见的字符,这会使一切都破碎。尝试删除此空格。

    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.38</version>
    </dependency>

2.删除您当地的maven存储库,再试一次。本地存储库通常为C:\Users\username\.m2\repository

3.控制您的代理设置。

我希望这会有所帮助。

答案 1 :(得分:0)

转到您的Maven存储库目录:

C:\Users\{user}\.m2\repository

寻找 mysql 文件夹并导航至:

C:\Users\{user}\.m2\repository\mysql\mysql-connector-java\5.1.6

在这里您将找到一个名为 mysql-connector-java-5.1.6.pom.lastUpdated 的文件。打开它并检查可能是什么问题。

就我而言

  

无法通过代理进行身份验证

这意味着我必须与代理断开连接,并与Wi-Fi或调制解调器连接,然后它才能工作。我希望这可以帮助加油