Maven 下载有.lastUpdated 作为扩展名

我有一个带有 m2eclipse 和 subversive 的 Eclipse 设置。我已经从 svn 导入了一个 maven2项目。但是我得到了一个错误消息,即一大堆工件都丢失了(例如: 丢失了工件 org.springFramework: spring-test: jar: 3.0.1)。释放: 测试)。

如果我查看存储库,我会看到 jar 文件,但是它们有一个额外的扩展名。最后更新。为什么 Maven 附加了。更新到罐子里了吗?更重要的是,我该怎么补救?

在我的 POM 中没有提到 lastUpdated 类型。

110584 次浏览

I installed Maven2 and ran mvn compile from the command line. This seems to have resolved the problem

you might have a problem with some of the artifacts to be retrieved from the repository. for example spring framework has its own repository. this xtension is appended when the artifact cannot fully downloaded. add the spring framework repository to your pom or settings.xml, delete the folder that include the broken jars and start again

As rperez said, I use to delete all those .lastUpdated files. In Linux I have created a little script to keep it simple:

find -name \*.lastUpdated -exec rm -fv {} +

Just create a file with the previous content and put it on your local Maven repository. Usually it will be ~/.m2/repository.

If you hit this problem and you're using Nexus, it might be the case that you have a routing rule defined, which is incorrect. I hit this myself and the files it was downloading were correctly named, at the proper URL-s it was looking at, but they were all with the .lastUpdated extension and an error message as contents.

These files indicate to Maven that it attempted to obtain the archive by download, but was unsuccessful. In order to save bandwidth it will not attempt this again until a certain time period encoded in the file has elapsed. The command line switch -U force maven to perform the update before the retry period. This may be necessary if you attempted to build while disconnected from the network.

The method of removing the files works with most versions of maven, but since the files are internal mementos to maven, I would not recommend this method. There is no guarantee that this information is not referenced or held elsewhere and such manipulation can damage the system.

Open your terminal, navigate to your Eclipse's project directory and run:

mvn install

If mvn install doesn't update your dependencies, then call it with a switch to force update:

mvn install -U

This is a much safer approach compared to tampering with maven files as you delete ".lastUpdated".

Use this command inside the .m2/repository dir to rename all files:

for file in `find . -iname *.lastUpdated`; do renamed=$(echo $file | rev | cut -c13- | rev); echo renaming: $file to $renamed; mv $file $renamed; done

This is usefull to not download all sources again.

This not work... The .jar is lost. :(

What I do when I encounter this issue:

Make sure you have the version of the latest 'maven-source-plugin' plugin: https://maven.apache.org/plugins/maven-source-plugin/usage.html

$ mvn source:jar install

Now if the file *.lastUpdate exist in your local ~/.m2/repositories/your-lib/0.0.1/ directory you can just remove it then run the command above again.

This is a side-effect of a failure to successfully extract from the repository. To get the actual content you want into your repository, check for correct paths to the repository/repositories within your pom file, and resolve certificate/security issues, if any. It is almost invariably one or the other of these issues.

There is no need to delete the .lastUpdated entries, and doing so won't solve your problem.