简体   繁体   English

Maven - 缺少神器

[英]Maven - missing artifact

I've just moved my project from windows to linux ubuntu. 我刚把我的项目从windows移到linux ubuntu。 After pulling files from repository it turned out that every pom.xml file consists errors. 从存储库中提取文件后,发现每个pom.xml文件都包含错误。 Not even one dependency injection isn't resolved. 甚至没有解决一个依赖注入。

I am using Spring Tool Suite Eclipse extension and have maven2 downloaded. 我正在使用Spring Tool Suite Eclipse扩展并已下载maven2。

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. 编辑:在控制台中键入“mvn clean install -U”并物理地下载几个jar后我设法将问题减少到只有一个pom.xml,但它仍然指向文件中的错误,这在Windows中是正确的。

There is my pom.xml: 有我的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. ArtifactDescriptorException:无法读取ch.qos.logback的工件描述符:logback-classic:jar:1.0.7:ArtifactResolutionException:无法从http://下载传输ch.qos.logback:logback-classic:pom:1.0.7 .java.net / maven / 2缓存在本地存储库中,在java.net2的更新间隔过去或强制更新之前,不会重新尝试解析。 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. 原始错误:无法传输工件ch.qos.logback:logback-classic:pom:1.0.7 from / to java.net2( http://download.java.net/maven/2 ):操作已取消。

  2. Missing artifact aopalliance:aopalliance:jar:1.0 缺失神器aopalliance:aopalliance:jar:1.0

  3. Parent of resource: /home/user/workspace/artifact/name/target/classes/META-INF is marked as read-only. 资源的父级:/ home / user / workspace / artifact / name / target / classes / META-INF标记为只读。

  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' 容器'Maven Dependencies'引用非现有库'/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. 对于少数情况,每一次重复。

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. 很有可能,Maven设置不同,您只是忘记将一些存储库配置等移动到新位置。

Please check global Maven settings.xml or user-specific: ~/.m2/settings.xml on Linux and C:\\User\\[username]\\.m2\\settings.xml on Windows. 请检查全局Maven settings.xml或用户特定的:Linux上的〜/ .m2 / settings.xml和Windows上的C:\\ User \\ [用户名] \\ 。m2 \\ settings.xml

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: 修复设置后(如果是原因),我建议运行Maven依赖插件目标'purge-loca-repository',从本地Maven存储库中删除项目的依赖项,并从头开始重新解析它们:

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: 关于aopalliance-1.0 artifact - >我还没有在java.net2 / sonatype存储库中找到它,所以请尝试使用Maven Central来解决它:

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

Good Luck! 祝好运!

i added this and it resolved my problem. 我添加了这个,它解决了我的问题。

<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-server -->
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-server</artifactId>
    <version>1.8</version>
</dependency>

There are few common causes related to maven migration 与maven迁移相关的常见原因很少

  • Your project consists of many internal dependencies (artifact created by yourself / colleagues) stored on your PC maven repository cache, as opposed in a shared internal repository. 您的项目包含存储在PC maven存储库缓存中的许多内部依赖项(由您自己/同事创建的工件),而不是共享内部存储库。 When you migrated into new PC it's no longer able to resolve these 当您迁移到新PC时,它不再能够解决这些问题
  • Your company has an internal maven repository (eg: nexus) and your project pom.xml isn't configured to search for this repository 您的公司有一个内部maven存储库(例如:nexus),您的项目pom.xml未配置为搜索此存储库
  • Your project is a multi module which aren't setup very neatly such that the topmost artifact in the dependecy map has to be installed first on your local repo before others can pull it 您的项目是一个多模块,它没有设置得非常整齐,因此必须首先在本地仓库中安装dependecy map中的最顶层工件,然后其他人才能将其拉出来
  • Your new pc repository use different maven version / jdk version combinations 您的新pc存储库使用不同的maven版本/ jdk版本组合

Your pc local repo is normally located at ~/.m2/repository 您的pc本地仓库通常位于〜/ .m2 / repository

If you use Cntlm as autetification proxy, check if it is alive in your Windows Tasks Manager: 如果您使用Cntlm作为autetification代理,请在Windows任务管理器中检查它是否处于活动状态:

cntlm.exe cntlm.exe

If not, try executing on a cmd window: 如果没有,请尝试在cmd窗口上执行:

call \path_to_your_cntlm_folder\Cntlm\cntlm.exe -c \path_to_your_cntlm_folder\Cntlm\cntlm.ini

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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