简体   繁体   中英

Maven Error in pom.xml using spring template

i am getting the following error in mi maven pom.xml on a spring template project

"Description Resource Path Location Type ArtifactDescriptorException: Failed to read artifact descriptor for org.slf4j:slf4j-api:jar:1.5.6: ArtifactResolutionException: Failure to transfer org.slf4j:slf4j-api:pom:1.5.6 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 org.slf4j:slf4j-api:pom:1.5.6 from/to central (http://repo.maven.apache.org/maven2): C:\Users\muhsin.HIFX.m2\repository\org\slf4j\slf4j-api\1.5.6\slf4j-api-1.5.6.pom.ahc0570cfa3a1934af5 (The system cannot find the file specified) pom.xml /sample line 1 Maven Dependency Problem"

my pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.springframework.samples.spring</groupId>
    <artifactId>spring-jpa-utility</artifactId>
    <version>1.0.0.CI-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>Spring JPA Utility</name>
    <url>http://www.springframework.org</url>
    <description>
        <![CDATA[This project is a minimal jar utility with Spring configuration for JPA usage.]]>
    </description>
    <properties>
        <maven.test.failure.ignore>true</maven.test.failure.ignore>
        <spring.framework.version>3.0.6.RELEASE</spring.framework.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>3.6.0.Final</version>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.framework.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.framework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.framework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.framework.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2.2</version>
        </dependency>       
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.156</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>
    </dependencies>

    <build>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>        
        </plugins>
    </build>

 <!--   <pluginRepositories>
        <pluginRepository>
            <id>Codehaus</id>
            <url>http://repository.codehaus.org/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
    <repositories>
        <repository>
            <id>org.jboss.repository.releases</id>
            <name>JBoss Maven Release Repository</name>
            <url>https://repository.jboss.org/nexus/content/repositories/releases</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    <distributionManagement>
        <downloadUrl>http://www.springframework.org/download</downloadUrl>
        <site>
            <id>staging</id>
            <url>file:///${user.dir}/target/staging/org.springframework.batch.archetype/${pom.artifactId}</url>
        </site>
        <repository>
            <id>spring-release</id>
            <name>Spring Release Repository</name>
            <url>file:///${user.dir}/target/staging/release</url>
        </repository>
        <snapshotRepository>
            <id>spring-snapshot</id>
            <name>Spring Snapshot Repository</name>
            <url>file:///${user.dir}/target/staging/snapshot</url>
        </snapshotRepository>
    </distributionManagement> -->
</project>

You can also use force update flag(-U) for example:

 mvn clean install -U

Based on the error message

"Description Resource Path Location Type ArtifactDescriptorException: Failed to read artifact descriptor for org.slf4j:slf4j-api:jar:1.5.6: ArtifactResolutionException: Failure to transfer org.slf4j:slf4j-api:pom:1.5.6 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.

it means you have to delete the folder $HOME/.m2/repository/org/slf4j and afterwards you need to rebuild via

mvn clean package

and other given error message:

Original error: Could not transfer artifact org.slf4j:slf4j-api:pom:1.5.6 from/to central (http://repo.maven.apache.org/maven2): C:\Users\muhsin.HIFX.m2\repository\org\slf4j\slf4j-api\1.5.6\slf4j-api-1.5.6.pom.ahc0570cfa3a1934af5 (The system cannot find the file specified) pom.xml /sample line 1 Maven Dependency Problem"

indicates that you have some kind of problem with you repository access. Either you have a proxy which is not correctly configured. What i recommend is to use a repository manager which makes life easier.

  1. You can try to run maven clean to perform a clean
  2. You can manually navigate to the specified file in your local repository and remove it and then try to download it as afresh copy using mvn clean install -e

open this location C:\Users...m2\repository\org\apache\maven\plugins\maven-surefire-plugin\2.10 Delete the file maven-surefire-plugin-2.10 and build the project.

it worked for me

Delete all the files present inside the folder **C:\Users\username.m2\repository** open eclipse again rebuild the project - (Give some time for eclipse IDE to Build the Workspace).

<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>

add this line in the properties. Worked for me!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM