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

Maven dependency:go-offline无法排除system scope依赖求助

解决Maven dependency:go-offline无法排除system scope依赖的方案

以下是几种可行的解决思路:

1. 升级maven-dependency-plugin版本

maven-dependency-plugin 3.5.0版本存在已知的excludeScope参数对system scope不生效的问题,建议升级到3.6.0及以上版本,修改插件配置如下:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>3.6.0</version>
  <executions>
    <execution>
      <id>go-offline-setup</id>
      <goals>
        <goal>go-offline</goal>
      </goals>
      <configuration>
        <excludeScope>system</excludeScope>
      </configuration>
    </execution>
  </executions>
</plugin>

2. 命令行添加强制跳过system scope的参数

在原有命令基础上添加-Dmaven.system.scope.skip=true参数,直接跳过system scope依赖的处理:

./mvnw -B dependency:go-offline -DexcludeScope=system -Dmaven.system.scope.skip=true

3. 临时通过Profile屏蔽system依赖(无需永久修改scope)

如果允许临时修改pom.xml,可以添加一个专用Profile,执行go-offline时激活,自动排除system scope依赖:

<profiles>
  <profile>
    <id>skip-system-deps</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>3.6.0</version>
          <executions>
            <execution>
              <id>go-offline-skip-system</id>
              <goals>
                <goal>go-offline</goal>
              </goals>
              <configuration>
                <excludeScope>system</excludeScope>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

执行时激活该Profile:

./mvnw -B dependency:go-offline -Pskip-system-deps

4. 用dependency:copy替代go-offline实现缓存

如果以上方法都无效,可以换用dependency:copy插件,仅下载非system scope的依赖到本地目录,实现缓存效果:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>3.6.0</version>
  <executions>
    <execution>
      <id>copy-non-system-deps</id>
      <goals>
        <goal>copy</goal>
      </goals>
      <configuration>
        <outputDirectory>${project.build.directory}/dependency-cache</outputDirectory>
        <excludeScope>system</excludeScope>
      </configuration>
    </execution>
  </executions>
</plugin>

执行命令触发:

./mvnw dependency:copy

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.11 21:42:11