gpt4 book ai didi

java - Maven 本地 Artifact 解析在 1 天后不起作用

转载 作者:行者123 更新时间:2023-11-30 08:51:16 25 4
gpt4 key购买 nike

我使用以下命令在本地存储库中安装我的 Artifact :

mvn install:install-file -DgroupId=com.rules 
-DartifactId=rulesID -Dversion=0.1 -Dpackaging=jar -Dfile=rules.jar

然后我使用以下方法将 Artifact 解析为我的 java 代码:

org.drools.compiler.kproject.ReleaseIdImpl releaseId = 
new ReleaseIdImpl("com.rules", "rulesID", "LATEST");

而且每件事都运作良好。

第二天,似乎存储库过期了,我需要另一个“mvn install”来让一切恢复正常。我得到的异常(exception)是:

Caused by: org.eclipse.aether.resolution.VersionResolutionException: 
Failed to resolve version for com.rules:rulesID:pom:LATEST: Could not find metadata com.rules:rulesID/maven-metadata.xml
in local (C:\Users\gpiazzolla\.m2\repository)
at org.apache.maven.repository.internal.DefaultVersionResolver.resolveVersion(DefaultVersionResolver.java:312)

事实上,该目录中的 maven-metadata.xml 似乎消失了。


重新安装后“maven-metadata-local.xml”的内容为:

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.rules</groupId>
<artifactId>rulesID</artifactId>
<versioning>
<release>0.1</release>
<versions>
<version>0.1</version>
</versions>
<lastUpdated>20150604080940</lastUpdated>
</versioning>
</metadata>

最佳答案

你的做法是错误的。一般来说,设计依赖于 Artifact 的非特定版本的软件不是最佳实践。此外,“LATEST”字段仅用于插件解析。请注意,LATEST 的工作方式可能并不总是保证使用最新版本。

Internally, Maven 2.x used the special version markers RELEASE and LATEST to support automatic plugin version resolution. These metaversions were also recognized in the element for a declaration. For the sake of reproducible builds, Maven 3.x no longer supports usage of these metaversions in the POM. As a result, users will need to replace occurrences of these metaversions with a concrete version. from Maven 3.x Compatibility Notes

如果您需要已发布的非插件 Artifact 的最高版本,您应该使用版本范围,请参阅第 3.4.3 节 herethis answer举个例子。

关于java - Maven 本地 Artifact 解析在 1 天后不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30637861/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com