本文介绍了Maven - 缺少神器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚把我的项目从windows移到linux ubuntu。从存储库中提取文件后,发现每个pom.xml文件都包含错误。甚至没有解决一个依赖注入问题。



我正在使用Spring Tool Suite Eclipse扩展并且已经下载了maven2。



可能导致什么?谢谢。



编辑:在控制台中键入mvn clean install -U并物理地下载几个罐子后,我设法将问题减少到只有一个pom.xml,但是它仍指向Windows中正确的文件错误。



有我的pom.xml:

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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>托管jee6工件的资源库< / 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>
<! - 春天 - >
< dependency>
< groupId> org.springframework< / groupId>
< artifactId> spring-context< / artifactId>
< version> $ {org.springframework-version}< / version>
< exclusions>
<! - 排除Commons登录有利于SLF4j - >
< exclusion>
< groupId> commons-logging< / groupId>
< artifactId> commons-logging< / artifactId>
< / exclusion>
< / exclusions>
< / dependency>

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

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

<! - 记录 - >
< 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>运行时< / 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>


我收到的错误是:


  1. ArtifactDescriptorException:无法读取ch.qos.logback的工件描述符:logback-classic:jar:1.0.7:ArtifactResolutionException :无法从缓存在本地存储库中,在经过java.net2的更新间隔或强制更新之前,不会重新尝试解析。原始错误:无法传输工件ch.qos.logback:logback-classic:pom:1.0.7 from / to java.net2():操作被取消了。


  2. 缺少工件aopalliance: aopalliance:jar:1.0


  3. 资源的父级:/ home / user / workspace / artifact / name / target / classes / META-INF标记为read-只有。


  4. 容器'Maven Dependencies'引用非现有库'/home/user/.m2/repository/org/springframework/spring-context/3.2 .2.RELEASE / spring-context-3.2.2.RELEASE.jar'


每一个都重复几个case。

解决方案

好的,所以你刚从一个操作系统转移到另一个操作系统......



很有可能,Maven设置不同,你只是忘了将一些存储库配置等移动到新的地方。



chec k全局Maven settings.xml或用户特定:Linux上的
〜/ .m2 / settings.xml C:\ User \ [username] \.m2 Windows上的\ setting.xml



您可能会发现一些有趣的事情。



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

  mvn依赖:purge-local-repository 

关于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>

祝你好运!


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.

解决方案

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]\.m2\settings.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!

这篇关于Maven - 缺少神器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 04:58