我在测试环境中从远程存储库更新 bundle 时遇到问题。环境包括多个带有 ServiceMix(或 Karaf,无论如何)的服务器和带有 JFrog Artifactory 的服务器。
在 karaf 3.0.X
之前,我们使用 SNAPSHOT 版本动态更新工作 OSGi 容器上的 bundle ,但现在 karaf 在本地存储库中搜索 bundle ,如果存在,则永远不会检查远程存储库(artifactory)上的最新版本。我该如何修复它?
karaf和maven的配置示例(为用户设置了M2_HOME
)
settings.xml ($M2_HOME/conf/settings.xml
)
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups/>
<proxies/>
<servers/>
<mirrors/>
<profiles>
<profile>
<id>default-repo-settings</id>
<activation>
<activeByDefault/>
</activation>
<repositories>
<repository>
<id>artifactory</id>
<url>http://artifactory/ext-snapshot-local</url>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
<!-- same repos here -->
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>default-repo-settings</activeProfile>
</activeProfiles>
</settings>
org.ops4j.pax.url.mvn.cfg($KARAF_HOME/etc/org.ops4j.pax.url.mvn.cfg
)
org.ops4j.pax.url.mvn.useFallbackRepositories=false
org.ops4j.pax.url.mvn.disableAether=true
org.ops4j.pax.url.mvn.useLocalRepositoryAsRemote=true
org.ops4j.pax.url.mvn.globalUpdatePolicy=always
org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}}/${karaf.default.repository}}@snapshots@id=karaf.${karaf.default.repository}}
org.ops4j.pax.url.mvn.repositories= \
http://artifactory/ext-snapshot-local@snapshots@id=artifactory, \
http://repo1.maven.org/maven2@id=central, \
http://repository.springsource.com/maven/bundles/release@id=spring.ebr.release, \
http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external, \
http://zodiac.springsource.com/maven/bundles/release@id=gemini, \
http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases, \
https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@noreleases, \
https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases
最佳答案
最好简化您的 Artifact 升级方法,以拥有且仅有一个位置将 Artifact 获取到 SMX/Karaf 容器。我建议设置您的 Artifactory,以便您拥有一个虚拟存储库,将您的内部存储库与远程存储库(Maven Central、Spring 等)合并。您的容器应该仅指向您内部的 Artifactory 实例。这还允许您的 Artifactory 缓存远程存储库,并且您不再依赖于互联网的启动和远程 Maven 存储库的启动。
现在,每当您执行“更新 $bundleId”时,它都会查询虚拟存储库,Artifactory 将为您提供 -SNAPSHOT Artifact 上的最佳可用匹配。
此外,从本地文件:repo 行中删除 @snapshots 可能是个好主意,以避免混淆。
关于java - 始终从远程存储库更新 bundle 或在 ServiceMix 6.0.X/Karaf 3.0.X 中禁用本地存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37389373/