Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
288 views
in Technique[技术] by (71.8m points)

java - Maven - missing artifact

I've just moved my project from windows to linux ubuntu. After pulling files from repository it turned out that every pom.xml file consists errors. Not even one dependency injection isn't resolved.

I am using Spring Tool Suite Eclipse extension and have maven2 downloaded.

What could cause that? Thanks.

EDIT: after typing "mvn clean install -U" in console and physicly downloading few jars I've managed to reduce problem to just one pom.xml, but it still points errors in file that is correct at windows.

There is my 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>id</groupId>
<artifactId>artifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>name</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java-version>1.7</java-version>
    <org.springframework-version>3.2.2.RELEASE</org.springframework-version>
    <org.slf4j-version>1.7.2</org.slf4j-version>
    <ch.qos.logback-version>1.0.7</ch.qos.logback-version>
</properties>

<repositories>
    <repository>
        <id>java.net2</id>
        <name>Repository hosting the jee6 artifacts</name>
        <url>http://download.java.net/maven/2</url>
    </repository>
    <repository>
        <id>sonatype-oss-repository</id>
        <url>https://oss.sonatype.org/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

<dependencies>
    <!-- Spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework-version}</version>
        <exclusions>
            <!-- Exclude Commons Logging in favor of SLF4j -->
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jms</artifactId>
        <version>3.2.2.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>javax.jms</groupId>
        <artifactId>javax.jms-api</artifactId>
        <version>2.0</version>
    </dependency>

    <!-- Logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${org.slf4j-version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${org.slf4j-version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${ch.qos.logback-version}</version>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.9.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>
</dependencies>

Errors that I receive are:

  1. ArtifactDescriptorException: Failed to read artifact descriptor for ch.qos.logback:logback-classic:jar:1.0.7: ArtifactResolutionException: Failure to transfer ch.qos.logback:logback-classic:pom:1.0.7 from http://download.java.net/maven/2 was cached in the local repository, resolution will not be reattempted until the update interval of java.net2 has elapsed or updates are forced. Original error: Could not transfer artifact ch.qos.logback:logback-classic:pom:1.0.7 from/to java.net2 (http://download.java.net/maven/2): The operation was cancelled.

  2. Missing artifact aopalliance:aopalliance:jar:1.0

  3. Parent of resource: /home/user/workspace/artifact/name/target/classes/META-INF is marked as read-only.

  4. The container 'Maven Dependencies' references non existing library '/home/user/.m2/repository/org/springframework/spring-context/3.2.2.RELEASE/spring-context-3.2.2.RELEASE.jar'

Every of these repeats for few cases.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Ok, so you've just moved from one OS to another...

There is a big chance, that Maven settings are different, and you just forgot to move some repositories configurations, etc. to the new place.

Please check global Maven settings.xml or user-specific: ~/.m2/settings.xml on Linux and C:User[username].m2settings.xml on Windows.

Chances are you'll find something interesting.

After fixing settings (if it's the cause), I would suggest to run Maven dependency plugin goal 'purge-loca-repository' for removing your project's dependencies from your local Maven repository and re-resolving them from scratch:

mvn dependency:purge-local-repository

Regarding aopalliance-1.0 artifact -> I haven't found it in java.net2/sonatype repositories, so please try Maven Central to resolve it:

<repository>
  <id>central</id>
  <name>Maven Central</name>
  <url>http://repo1.maven.org/maven2</url>
</repository>

Good Luck!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...