You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何将自定义本地项目添加至integration-distribution?

Troubleshooting Guide for Unresolvable ODL Startup Archetype Project

看起来你遇到的是用OpenDaylight启动原型创建项目后,无法从官方Nexus拉取依赖的问题,我来帮你一步步排查:

  • 检查Maven Settings配置
    首先确认你的settings.xml(一般在~/.m2/或Maven安装目录的conf/文件夹下)是否正确配置了OpenDaylight的快照仓库。如果你的Maven使用了公司镜像或自定义镜像,很可能会拦截对官方Nexus的请求。你可以在settings里添加专属的仓库配置:

    <profiles>
      <profile>
        <id>opendaylight</id>
        <repositories>
          <repository>
            <id>opendaylight-snapshot</id>
            <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
          </repository>
        </repositories>
      </profile>
    </profiles>
    <activeProfiles>
      <activeProfile>opendaylight</activeProfile>
    </activeProfiles>
    

    这样能确保Maven优先从ODL的快照仓库拉取依赖。

  • 清理本地Maven缓存
    有时候本地仓库里的缓存文件损坏或不完整,会导致依赖拉取失败。你可以执行以下命令强制清理并更新依赖:

    mvn clean install -U
    

    -U参数会强制Maven忽略本地快照缓存,重新从远程仓库拉取最新的依赖版本。

  • 查看调试日志定位具体错误
    你可以给Maven命令加上-X参数开启调试模式,这样能看到依赖拉取过程中的详细报错:

    mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeRepository=https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ -DarchetypeCatalog=remote -DarchetypeVersion=1.6.0-SNAPSHOT -X
    

    从日志里能明确是仓库不可达、版本不存在还是权限问题,方便精准解决。

  • 检查Distribution中的Karaf配置
    既然你已经把项目添加到distribution并启动了Karaf,别忘了检查:

    • 你的项目feature.xml是否正确定义了所有依赖
    • distribution的pom.xml是否已经包含你的项目模块
      同时可以查看Karaf的data/log/karaf.log日志,里面会详细记录哪些依赖无法解析,跟着日志定位具体的问题包。
  • 尝试切换到稳定版本
    你使用的1.6.0-SNAPSHOT是较老旧的Oxygen系列快照版本,可能存在仓库同步问题。可以试试同系列的稳定版本,比如1.5.3,把命令改成:

    mvn archetype:generate -DarchetypeGroupId=org.opendaylight.controller -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeRepository=https://nexus.opendaylight.org/content/repositories/opendaylight.release/ -DarchetypeCatalog=remote -DarchetypeVersion=1.5.3
    

    稳定版本的依赖通常更可靠,不会出现快照仓库的临时同步问题。

如果以上步骤都试过还是有问题,可以把Maven调试日志或Karaf日志里的具体错误片段贴出来,这样能更精准地定位问题。

内容的提问来源于stack exchange,提问作者Max

火山引擎 最新活动