Maven 找不到我的离线依赖项/本地工件(“在本地存储库中不可用”)?

Kat*_*tie 1 maven-3 maven

我正在尝试下载我所有的依赖项并使它们脱机可用,但是当我运行时mvn -o test,它说The repository system is offline but the artifact commons-io:commons-io:jar:2.4 is not available in the local repository. 但是,我的~/.m2/repository!

~/.m2/settings.xml

<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
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>${user.home}/.m2/repository</localRepository>
  <interactiveMode>true</interactiveMode>
  <usePluginRegistry>false</usePluginRegistry>
  <offline>true</offline>
</settings>
Run Code Online (Sandbox Code Playgroud)

ls ~/.m2/repository/commons-io/commons-io/2.4/

 _maven.repositories
 commons-io-2.4.jar
 commons-io-2.4.jar.lastUpdated
 commons-io-2.4.jar.sha1
 commons-io-2.4.pom
 commons-io-2.4.pom.sha1
Run Code Online (Sandbox Code Playgroud)

mvn -o 测试

[错误] 无法在项目 myproject 上执行目标 com.github.temyers:cucumber-jvm-parallel-plugin:2.0.2:generateRunners (generateRunners):执行目标 com.github.temyers:cucumber-jvm-parallel-plugin 的 generateRunners :2.0.2:generateRunners failed: Plugin com.github.temyers:cucumber-jvm-parallel-plugin:2.0.2 或其依赖项之一无法解析:

存储库系统离线,但工件 commons-io:commons-io:jar:2.4 在本地存储库中不可用。-> [帮助 1]

问题

基本上maven 说我没有 ~/.m2/repository/commons-io/commons-io/2.4/,但我

我试过这个:

find ~/.m2/repository -name _maven.repositories -exec rm -v {} \;
Run Code Online (Sandbox Code Playgroud)

但是删除_maven.repositories后,当我运行时mvn -o test文件又回来了

我有专家 3.0.5

Kat*_*tie 5

这三件事让它起作用(感谢@Tunaki)

  1. 放在-omvn 命令的末尾。例子mvn test -o。刚开始用的时候,没用
  2. 删除所有*.lastUpdated文件。
    • find ~/.m2/repository -name *.lastUpdated -exec rm -v {} \;
  3. 删除所有_maven.repositories文件。
    • find ~/.m2/repository -name _maven.repositories -exec rm -v {} \;

注意settings.xml无论它在那里还是被删除都没有区别。所以我认为它没有做任何事情。

  • `-o` 的位置确实不应该改变任何东西。 (2认同)