在本地找不到元数据

问题描述:

在本地机器上,我安装了带有Maven存储库的Artifactory,并且我的项目有一个非常简单的.pom文件,指向该文件:

Locally on the machine i have an Artifactory installed with maven repositories, and i have a very simple .pom file for my project which points to it:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>MYGROUP</groupId>
    <artifactId>NAME</artifactId>
    <packaging>jar</packaging>
    <version>VERSION</version>
    <build>
        <sourceDirectory>SRCFOLDER</sourceDirectory>
        <testSourceDirectory>TESTFOLDER</testSourceDirectory>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>

    </build>

    <repositories>
        <repository>
            <id>local-artifactory</id>
            <name>Artifactory</name>
            <url>http://localhost:8081/artifactory/repo</url>
            <layout>default</layout>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>local-artifactory-plugins</id>
            <name>Artifactory Plugins</name>
            <url>http://localhost:8081/artifactory/repo</url>
        </pluginRepository>
    </pluginRepositories>

<dependencies>
    <dependency>
        <groupId>MYGROUP</groupId>
        <artifactId>DEPENDENCY1</artifactId>
        <version>bla-SNAPSHOT</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>MYGROUP</groupId>
        <artifactId>DEPENDENCY2</artifactId>
        <version>bla-SNAPSHOT</version>
        <scope>compile</scope>
    </dependency>
</dependencies>
</project>

所以我声明了本地人工存储库,目的是每次都会重新加载所有内容.我也有几个依赖关系,即快照.

So i have local-artifactory repository declared with the intention that it will reload everything every time. Also i have couple of dependencies which are SNAPSHOTS.

现在我正在使用maven 3.0.5,并且在我对其进行编译时,它可以正常工作,但它根本不刷新快照.绝不.曾经.日志文件如下所示:

Now i'm using maven 3.0.5, and when i'm compiling it it works fine, but it's not refreshing snapshots at all. Never. Ever. Log file looks like this:

[DEBUG] Could not find metadata MYGROUP:DEPENDENCY1:bla-SNAPSHOT/maven-metadata.xml in local (/opt/myuser/.m2/repository)
[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://localhost:8081/artifactory/repo
Downloading: http://localhost:8081/artifactory/repo/MYGROUP/DEPENDENCY1/bla-SNAPSHOT/maven-metadata.xml
Downloaded: http://localhost:8081/artifactory/repo/MYGROUP/DEPENDENCY1/bla-SNAPSHOT/maven-metadata.xml (314 B at 13.9 KB/sec)
[DEBUG] Writing resolution tracking file /opt/myuser/.m2/repository/MYGROUP/DEPENDENCY1/bla-SNAPSHOT/resolver-status.properties
[DEBUG] Could not find metadata MYGROUP:DEPENDENCY1:bla-SNAPSHOT/maven-metadata.xml in local (/opt/myuser/.m2/repository)
[DEBUG] Skipped remote update check for MYGROUP:DEPENDENCY1:bla-SNAPSHOT/maven-metadata.xml, already updated during this session.

因此,它一直抱怨它找不到本地maven-medatada.xml,当然他是完全正确的-它不存在.却无能为力.

So it constantly complains that it can't find local maven-medatada.xml and of course he's completely right - it's not there. And fails to do ANYTHING with it.

因此,我尝试使用dependency:purge-local-repository清除本地库存并猜测是什么?显然它不能清除它,因为每个工件中都没有maven-metadata.xml,这真是一个了不起的功能!

So i've tried to use dependency:purge-local-repository to purge local inventory and guess what? Apparently it can't purge it because there is no maven-metadata.xml in each artifact, what an amazing functionality!

除了.jar和.pom之外的每个.m2工件目录都包含maven-metadata-local-artifactory.xml(具有来自工件(当前)的maven-metadata.xml的正确副本),_mave.repositories和resolver-status .properties.

Each .m2 artifact directory apart of .jar and .pom contains maven-metadata-local-artifactory.xml(with the correct copy of maven-metadata.xml from the artifactory, current), _mave.repositories and resolver-status.properties.

Maven是开箱即用的,.m2中没有配置,/conf文件夹中的配置是默认设置,没有任何更改.

Maven is just out of the box, there is no configuration in .m2 and the configuration in the /conf folder is default without any single change.

更新:我刚刚从工件上手动下载了maven-metadata.xml并将其作为.m2内的maven-metadata.xml进行了依赖-无效,它仍然在丢失"它.所以我不知道它要我什么了.它只是无法更新依赖项,因为已在此会话中更新".好吧,我不知道它究竟更新了什么,但是显然还有其他东西.

UPDATE: I've just manually downloaded maven-metadata.xml from the artifactory and placed it as maven-metadata.xml inside .m2 for a dependency - no effect, it is still "missing" it. So i don't have any idea what it wants from me anymore. It just can't update dependencies because "already updated during this session". Well i don't know what it updated exactly, but apparently something else.

UPDATE2:服务器上maven-metadata.xml的内容:

UPDATE2: Contents of maven-metadata.xml on the server:

<metadata>
    <groupId>MYGROUP</groupId> 
    <artifactId>DEPENDENCY1</artifactId> 
    <version>bla-SNAPSHOT</version> 
    <versioning>
        <snapshot>
            <buildNumber>1</buildNumber> 
        </snapshot>
        <lastUpdated>20130322155759</lastUpdated> 
    </versioning>
</metadata>

在maven元数据xml文件中,您似乎正在使用存储库中的非唯一快照. Maven 3不支持带有TIMESTAMP-BUILDNUMBER而不是SNAPSHOT的非唯一快照POM文件.你有吗?

From the maven metadata xml file it looks like you are using non-unique snapshot in your repository. Maven 3 does not supports non-unique, only snapshot pom file with TIMESTAMP-BUILDNUMBER instead of SNAPSHOT. Do you have:

http://localhost:8081/artifactory/repo/MYGROUP/DEPENDENCY1/bla-SNAPSHOT/DEPENDENCY1-bla-XXXXX-Y.pom

文件?