Maven 本地工件解析在 1 天后不起作用
Maven local artifacts resolution does not work after 1 day
我使用以下命令在本地存储库中安装我的工件:
mvn install:install-file -DgroupId=com.rules
-DartifactId=rulesID -Dversion=0.1 -Dpackaging=jar -Dfile=rules.jar
然后我将工件解析为我的 java 代码,使用:
org.drools.compiler.kproject.ReleaseIdImpl releaseId =
new ReleaseIdImpl("com.rules", "rulesID", "LATEST");
而且每件事都运作良好。
第二天,存储库似乎过期了,我需要另一个 "mvn install" 才能让一切恢复正常。我得到的例外是:
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>
你的做法是错误的。
一般来说,设计依赖于工件的非特定版本的软件不是最佳实践。此外,"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
如果您需要已发布的非插件工件的最高版本,您应该使用版本范围,请参阅第 3.4.3 节here or this answer 举个例子。
我终于搞定了。
当使用 Drools 实现查找工件并且 maven 存储库是本地而非远程时存在错误。
看看这个:DROOLS-465
我使用以下命令在本地存储库中安装我的工件:
mvn install:install-file -DgroupId=com.rules
-DartifactId=rulesID -Dversion=0.1 -Dpackaging=jar -Dfile=rules.jar
然后我将工件解析为我的 java 代码,使用:
org.drools.compiler.kproject.ReleaseIdImpl releaseId =
new ReleaseIdImpl("com.rules", "rulesID", "LATEST");
而且每件事都运作良好。
第二天,存储库似乎过期了,我需要另一个 "mvn install" 才能让一切恢复正常。我得到的例外是:
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>
你的做法是错误的。 一般来说,设计依赖于工件的非特定版本的软件不是最佳实践。此外,"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
如果您需要已发布的非插件工件的最高版本,您应该使用版本范围,请参阅第 3.4.3 节here or this answer 举个例子。
我终于搞定了。 当使用 Drools 实现查找工件并且 maven 存储库是本地而非远程时存在错误。
看看这个:DROOLS-465