You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

解决screen-recorder的Maven依赖配置及Artifactory无pom.xml问题

解决Maven拉取screen-recorder的配置方案

针对你遇到的两个问题——Artifactory找不到对应pom、构建时会尝试访问Oracle仓库,这里有两种可靠的配置方案:

方案一:直接在项目pom.xml中配置目标仓库与依赖

这种方式不需要修改全局settings.xml,所有项目成员共享配置,能避免环境差异导致的构建失败:

  • 添加目标仓库到pom.xml
    在<project>标签内添加<repositories>节点,指向Jenkins的发布仓库,这样Maven会优先从这里拉取screen-recorder的资源:

    <repositories>
        <repository>
            <id>jenkins-releases</id>
            <url>http://repo.jenkins-ci.org/releases/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    
  • 声明screen-recorder依赖
    在<dependencies>节点中添加依赖,指定版本0.7.7:

    <dependency>
        <groupId>org.monte</groupId>
        <artifactId>screen-recorder</artifactId>
        <version>0.7.7</version>
    </dependency>
    

    这个仓库里应该包含对应的pom.xml文件,如果确实不存在,你可以手动添加<scope>system</scope>并指定jar的本地路径,但不推荐system scope(会导致依赖不可移植),优先确认Jenkins仓库的完整资源。

  • 屏蔽不必要的Oracle仓库访问
    如果构建时访问Oracle仓库是因为其他依赖的间接引入,你可以在对应的依赖中排除Oracle相关的传递依赖,或者在pom的<repositories>里只保留必要的仓库(比如你的Artifactory和Jenkins仓库),避免Maven去遍历其他无关仓库。

方案二:修改全局settings.xml(适合团队统一配置)

如果团队需要统一仓库配置,可以修改settings.xml,确保所有成员的构建都指向正确的仓库:

  • 添加Jenkins仓库到<profiles>并激活
    在settings.xml的<profiles>中添加包含Jenkins仓库的profile:

    <profile>
        <id>jenkins-repo-profile</id>
        <repositories>
            <repository>
                <id>jenkins-releases</id>
                <url>http://repo.jenkins-ci.org/releases/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
            </repository>
        </repositories>
    </profile>
    

    然后激活这个profile,让Maven默认使用:

    <activeProfiles>
        <activeProfile>jenkins-repo-profile</activeProfile>
    </activeProfiles>
    
  • 屏蔽Oracle仓库
    如果settings.xml中配置了Oracle仓库,可以直接注释或删除对应的<repository>或<mirror>节点;如果是依赖传递导致的访问,还是建议在项目pom中排除对应的传递依赖,这样更灵活。

额外提示

  • 建议优先使用方案一,因为项目级配置能确保所有成员拉取依赖的逻辑一致,不会因为个人settings.xml的差异出问题;
  • 如果内部Artifactory可以配置远程仓库代理,你可以把Jenkins的这个仓库添加为Artifactory的远程代理,这样后续构建都可以从内部Artifactory拉取,速度更快也更稳定。

内容的提问来源于stack exchange,提问作者Stéphane GRILLON

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:54:28