当maven说“在MyRepo的更新间隔过去之前不会重新尝试解析”时,该间隔在哪里指定?

发布于 2024-10-15 07:29:06 字数 620 浏览 7 评论 0原文

使用 Maven,我偶尔会遇到来自某些 3rd 方存储库的工件,但我尚未构建或包含在我的存储库中。

我将从 Maven 客户端收到一条错误消息,指出找不到工件:

找不到 org.jfrog.maven.annomojo:maven-plugin-anno:jar:1.4.0 http://myrepo:80/artifactory/repo 中被缓存在本地 存储库,在更新之前不会重新尝试解析 MyRepo 的间隔已过或强制更新 -> [帮助1]

现在,明白这意味着什么,并且可以简单地使用 -U 重新运行我的命令,从那时起事情通常会正常工作

然而,我发现这个错误消息非常不直观,我试图让我的同事免于一些麻烦。

我试图弄清楚是否有地方可以修改此更新间隔设置。

  1. 此错误消息中提到的更新间隔是客户端设置还是服务器端设置?
  2. 如果是客户端,如何配置?
  3. 如果是服务器端,有谁知道 Nexus/Artifactory 如何/是否公开这些设置?

With maven, I occasionally hit an artifact that comes from some 3rd-party repo that I haven't built or included in my repository yet.

I'll get an error message from the maven client saying that an artifact can't be found:

Failure to find org.jfrog.maven.annomojo:maven-plugin-anno:jar:1.4.0
in http://myrepo:80/artifactory/repo was cached in the local
repository, resolution will not be reattempted until the update
interval of MyRepo has elapsed or updates are forced -> [Help 1]

Now, I understand what this means, and can simply re-run my command with -U, and things usually work fine from there on out.

However, I find this error message to be extremely unintuitive and am trying to spare my co-workers some headaches.

I am trying to figure out if there is some place that I can modify this update interval setting.

  1. Is the update interval that is mentioned in this error message a client-side or server-side setting?
  2. If client-side, how do I configure it?
  3. If server-side, does anyone know how/if Nexus/Artifactory expose these settings?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(26

浅紫色的梦幻 2024-10-22 07:29:06

我曾经通过删除本地存储库中相应的无法下载工件目录来解决此问题。下次我运行 Maven 命令时,会再次触发工件下载。因此我会说这是客户端设置。

Nexus端(服务器repo端),这个问题是通过配置计划任务来解决的。
客户端,这是使用 -U 完成的,正如您已经指出的那样。

I used to solve this issue by deleting the corresponding failed to download artifact directory in my local repo. Next time I run the maven command the artifact download is triggered again. Therefore I'd say it's a client side setting.

Nexus side (server repo side), this issue is solved configuring a scheduled task.
Client side, this is done using -U, as you already pointed out.

笑咖 2024-10-22 07:29:06

基本上发生的事情是,根据 maven 的默认 updatePolicy,maven 每天都会从 repo 中获取 jar。因此,如果在第一次尝试期间您的互联网无法正常工作,那么在 24 小时过去之前,它不会再次尝试获取此 jar。

解决方案:

使用

mvn -U clean install

(其中 -U 将强制更新存储库)

使用

<profiles>
    <profile>
      ...
      <repositories>
        <repository>
          <id>myRepo</id>
          <name>My Repository</name>
          <releases>
            <enabled>false</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
         </repository>
      </repositories>
      ...
    </profile>
  </profiles>

或在 settings.xml 中

What basically happens is, according to the default updatePolicy of maven, maven will fetch the jars from the repo on a daily basis. So if during the first attempt your Internet was not working, then it would not try to fetch this jar again until 24hours has passed.

Resolution:

Either use

mvn -U clean install

(where -U will force update the repo)

or use

<profiles>
    <profile>
      ...
      <repositories>
        <repository>
          <id>myRepo</id>
          <name>My Repository</name>
          <releases>
            <enabled>false</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
         </repository>
      </repositories>
      ...
    </profile>
  </profiles>

in your settings.xml

鹿! 2024-10-22 07:29:06

您可以删除本地存储库中相应的失败工件目录。您也可以简单地在目标中使用 -U 。它会完成工作。这适用于 maven 3。因此无需降级到 maven 2。

you can delete the corresponding failed artifact directory in you local repository. And also you can simply use the -U in the goal. It will do the work. This works with maven 3. So no need to downgrade to maven 2.

云雾 2024-10-22 07:29:06

我有一个相关的问题,但拉古拉姆的回答有帮助。 (我还没有足够的声誉来投票支持他的答案)。我正在使用与 NetBeans 捆绑在一起的 Maven,并得到相同的“...已缓存在本地存储库中,在 nexus 的更新间隔已过或强制更新之前,不会重新尝试解析 -> [帮助 1]”错误。

为了解决这个问题,我将 always 添加到我的设置文件 (C:\Program Files\NetBeans 7.0\java\maven\conf\settings.xml)

<profile>
  <id>nexus</id>
  <!--Enable snapshots for the built in central repo to direct -->
  <!--all requests to nexus via the mirror -->
  <repositories>
    <repository>
      <id>central</id>
      <url>http://central</url>
      <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
      <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
    </repository>
  </repositories>
 <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <url>http://central</url>
      <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
      <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
    </pluginRepository>
  </pluginRepositories>
</profile>

I had a related problem, but Raghuram's answer helped. (I don't have enough reputation yet to vote his answer up). I'm using Maven bundled with NetBeans, and was getting the same "...was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]" error.

To fix this I added <updatePolicy>always</updatePolicy> to my settings file (C:\Program Files\NetBeans 7.0\java\maven\conf\settings.xml)

<profile>
  <id>nexus</id>
  <!--Enable snapshots for the built in central repo to direct -->
  <!--all requests to nexus via the mirror -->
  <repositories>
    <repository>
      <id>central</id>
      <url>http://central</url>
      <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
      <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
    </repository>
  </repositories>
 <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <url>http://central</url>
      <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
      <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
    </pluginRepository>
  </pluginRepositories>
</profile>
长途伴 2024-10-22 07:29:06

虽然您可以通过干净安装(覆盖任何缓存的依赖项)来解决此问题,正如 @Sanjeev-Gulgani 建议的 mvn -U clean install

您也可以简单地删除导致问题的缓存依赖项,

mvn dependency:purge-local-repository -DmanualInclude="groupId:artifactId"

请参阅 < a href="http://maven.apache.org/plugins/maven-dependency-plugin/purge-local-repository-mojo.html" rel="noreferrer">mvn 文档 了解更多信息。

While you can resolve this with a clean install (overriding any cached dependencies) as @Sanjeev-Gulgani suggests with mvn -U clean install

You can also simply remove the cached dependency that is causing the problem with

mvn dependency:purge-local-repository -DmanualInclude="groupId:artifactId"

See mvn docs for more info.

情话墙 2024-10-22 07:29:06

根据设置参考

updatePolicy: 此元素指定尝试进行更新的频率。 Maven会比较本地POM的时间戳(存储
在存储库的 maven-metadata 文件中)到远程。 选择是:
总是、每天(默认)、间隔:X(其中 X 是以分钟为单位的整数)
或者永远不会。

示例:

<profiles>
    <profile>
      ...
      <repositories>
        <repository>
          <id>myRepo</id>
          <name>My Repository</name>
          <releases>
            <enabled>false</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
         </repository>
      </repositories>
      ...
    </profile>
  </profiles>
  ...
</settings>

According to the settings reference:

updatePolicy: This element specifies how often updates should attempt to occur. Maven will compare the local POM’s timestamp (stored
in a repository’s maven-metadata file) to the remote. The choices are:
always, daily (default), interval:X (where X is an integer in minutes)
or never.

Example:

<profiles>
    <profile>
      ...
      <repositories>
        <repository>
          <id>myRepo</id>
          <name>My Repository</name>
          <releases>
            <enabled>false</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
         </repository>
      </repositories>
      ...
    </profile>
  </profiles>
  ...
</settings>
迷爱 2024-10-22 07:29:06

从本地 Maven 存储库中删除相关依赖项后,此操作将起作用

/user/.m2/repository/path

This works after you delete the related dependency from your local maven repository

/user/.m2/repository/path
从此见与不见 2024-10-22 07:29:06

此错误有时可能会产生误导。您可能需要检查两件事:

  1. 存储库中是否有依赖项的实际 JAR?您的错误消息包含正在搜索的 URL,因此请转到那里,然后浏览到与您的依赖项匹配的文件夹。有罐子吗?如果没有,您需要改变您的依赖关系。 (例如,当您应该指向子项目时,您可能会指向顶级父依赖项)

  2. 如果远程存储库上存在该 jar,则只需删除本地副本。它将位于您的主目录(除非您配置不同)下的 .m2/repository(如果在 Linux 上,则 ls -a 显示隐藏)。

This error can sometimes be misleading. 2 things you might want to check:

  1. Is there an actual JAR for the dependency in the repo? Your error message contains a URL of where it is searching, so go there, and then browse to the folder that matches your dependency. Is there a jar? If not, you need to change your dependency. (for example, you could be pointing at a top level parent dependency, when you should be pointing at a sub project)

  2. If the jar exists on the remote repo, then just delete your local copy. It will be in your home directory (unless you configured differently) under .m2/repository (ls -a to show hidden if on Linux).

箹锭⒈辈孓 2024-10-22 07:29:06

如果您使用的是 Eclipse,请转到 Windows ->首选项-> Maven 并取消选中“不自动更新远程存储库的依赖项”复选框。

这也适用于 Maven 3。

If you are using Eclipse then go to Windows -> Preferences -> Maven and uncheck the "Do not automatically update dependencies from remote repositories" checkbox.

This works with Maven 3 as well.

弄潮 2024-10-22 07:29:06

您需要从存储库中删除所有“_maven.repositories”文件。

You need to delete all "_maven.repositories" files from your repository.

夜灵血窟げ 2024-10-22 07:29:06

我在使用不同的工件时遇到了类似的错误。

<...>已缓存在本地存储库中,不会重新尝试解析
直到central的更新间隔已过或强制更新

上述解决方案都不适合我。我终于在 IntelliJ IDEA 中解决了这个问题
文件>使缓存无效/重新启动...>无效并重新启动

I had a similar error with a different artifact.

<...> was cached in the local repository, resolution will not be reattempted
until the update interval of central has elapsed or updates are forced

None of the above described solutions worked for me. I finally resolved this in IntelliJ IDEA by
File > Invalidate Caches / Restart ... > Invalidate and Restart.

宫墨修音 2024-10-22 07:29:06

对于Intellij用户,以下对我有用:

右键单击您的包

Maven > Reimport 

Maven > Generate Sources and Update Folders

For Intellij users the following worked for me:

Right click on your package

Maven > Reimport 

and

Maven > Generate Sources and Update Folders
情场扛把子 2024-10-22 07:29:06

如果您使用 Nexus 作为代理存储库,它具有“未找到缓存 TTL”设置,默认值为 1440 分钟(或 24 小时)。降低此值可能会有所帮助(存储库 > 配置 > 过期设置)。

有关详细信息,请参阅文档

If you use Nexus as a proxy repo, it has "Not Found Cache TTL" setting with default value 1440 minutes (or 24 hours). Lowering this value may help (Repositories > Configuration > Expiration Settings).

See documentation for more info.

悲喜皆因你 2024-10-22 07:29:06

最后回答标题问题:它是(项目、配置文件或设置)

[plugin]?[r|R]epository/[releases|snapshots]/updatePolicy

...标签中的(客户端设置)。

(目前,maven:3.6.0,但我认为“向后”兼容)可能的值是:

<前><代码>/**
* 永远不要更新本地缓存的数据。
*/
公共静态最终字符串 UPDATE_POLICY_NEVER = "从不";
/**
* 始终更新本地缓存的数据。
*/
公共静态最终字符串 UPDATE_POLICY_ALWAYS = "始终";
/**
* 每天更新一次本地缓存数据。
*/
公共静态最终字符串 UPDATE_POLICY_DAILY = "每日";
/**
* 每 X 分钟更新一次本地缓存的数据,由“interval:X”指定。
*/
公共静态最终字符串 UPDATE_POLICY_INTERVAL = "间隔";

当前(maven 3.6.0)对该标签的评估实现如下:

public boolean isUpdatedRequired( RepositorySystemSession session, long lastModified, String policy )
{
    布尔值 checkForUpdates;
    如果(政策==空)
    {
        政策=“”;
    }
    如果(RepositoryPolicy.UPDATE_POLICY_ALWAYS.equals(策略))
    {
        检查更新=真;
    }
    否则如果(RepositoryPolicy.UPDATE_POLICY_DAILY.equals(策略))
    {
        日历 cal = Calendar.getInstance();
        cal.set( 日历.HOUR_OF_DAY, 0 );
        cal.set( 日历.MINUTE, 0 );
        cal.set( 日历.SECOND, 0 );
        cal.set( 日历.MILLISECOND, 0 );
        checkForUpdates = cal.getTimeInMillis() > >最后修改;
    }
    否则如果(policy.startsWith(RepositoryPolicy.UPDATE_POLICY_INTERVAL))
    {
        int 分钟 = getMinutes( 策略 );
        日历 cal = Calendar.getInstance();
        cal.add(Calendar.MINUTE, -分钟);
        checkForUpdates = cal.getTimeInMillis() > >最后修改;
    }
    别的
    {
        // 假设“从不”
        检查更新=假;
        if ( !RepositoryPolicy.UPDATE_POLICY_NEVER.equals( 策略 ) )
        {
            LOGGER.warn( "未知的存储库更新策略'{}',假设'{}'",
                    策略,RepositoryPolicy.UPDATE_POLICY_NEVER );
        }
    }
    返回检查更新;
}

..和:

private int getMinutes( 字符串策略 )
{
    分钟;
    尝试
    {
        String s = policy.substring( RepositoryPolicy.UPDATE_POLICY_INTERVAL.length() + 1 );
        分钟 = Integer.valueOf( s );
    }
    捕获(运行时异常 e)
    {
        分钟 = 24 * 60;
        LOGGER.warn( "不可解析的存储库更新策略 '{}',假设 '{}:1440'",
                策略,RepositoryPolicy.UPDATE_POLICY_INTERVAL );
    }
    返回分钟数;
}

...其中 lastModified 是每个底层工件的(本地文件)“修改时间戳”。


特别是对于 interval:x 设置:

  • 冒号 : 并不那么严格 - 任何“非空”字符都可以做到这一点(=,...)。
  • 负值 x < 0 应该屈服于“从不”。
  • interval:0 我会假设“每分钟”(0-59 秒或以上...)间隔。
  • 数字格式异常会导致 24 * 60 分钟(~“每日”)。

..参见: DefaultUpdatePolicyAnalyzerDefaultMetadataResolver#resolveMetadata()RepositoryPolicy

To finally answer the title question: It is (a client side setting) in (project, profile or settings)

[plugin]?[r|R]epository/[releases|snapshots]/updatePolicy

... tag.

The (currently, maven: 3.6.0, but I suppose "far backwards" compatible) possible values are :

/**
 * Never update locally cached data.
 */
public static final String UPDATE_POLICY_NEVER = "never";
/**
 * Always update locally cached data.
 */
public static final String UPDATE_POLICY_ALWAYS = "always";
/**
 * Update locally cached data once a day.
 */
public static final String UPDATE_POLICY_DAILY = "daily";
/**
 * Update locally cached data **every X minutes** as given by "interval:X".
 */
public static final String UPDATE_POLICY_INTERVAL = "interval";

The current (maven 3.6.0) evaluation of this tag is implemented as follows:

public boolean isUpdatedRequired( RepositorySystemSession session, long lastModified, String policy )
{
    boolean checkForUpdates;
    if ( policy == null )
    {
        policy = "";
    }
    if ( RepositoryPolicy.UPDATE_POLICY_ALWAYS.equals( policy ) )
    {
        checkForUpdates = true;
    }
    else if ( RepositoryPolicy.UPDATE_POLICY_DAILY.equals( policy ) )
    {
        Calendar cal = Calendar.getInstance();
        cal.set( Calendar.HOUR_OF_DAY, 0 );
        cal.set( Calendar.MINUTE, 0 );
        cal.set( Calendar.SECOND, 0 );
        cal.set( Calendar.MILLISECOND, 0 );
        checkForUpdates = cal.getTimeInMillis() > lastModified;
    }
    else if ( policy.startsWith( RepositoryPolicy.UPDATE_POLICY_INTERVAL ) )
    {
        int minutes = getMinutes( policy );
        Calendar cal = Calendar.getInstance();
        cal.add( Calendar.MINUTE, -minutes );
        checkForUpdates = cal.getTimeInMillis() > lastModified;
    }
    else
    {
        // assume "never"
        checkForUpdates = false;
        if ( !RepositoryPolicy.UPDATE_POLICY_NEVER.equals( policy ) )
        {
            LOGGER.warn( "Unknown repository update policy '{}', assuming '{}'",
                    policy, RepositoryPolicy.UPDATE_POLICY_NEVER );
        }
    }
    return checkForUpdates;
}

..with:

private int getMinutes( String policy )
{
    int minutes;
    try
    {
        String s = policy.substring( RepositoryPolicy.UPDATE_POLICY_INTERVAL.length() + 1 );
        minutes = Integer.valueOf( s );
    }
    catch ( RuntimeException e )
    {
        minutes = 24 * 60;
        LOGGER.warn( "Non-parseable repository update policy '{}', assuming '{}:1440'",
                policy, RepositoryPolicy.UPDATE_POLICY_INTERVAL );
    }
    return minutes;
}

...where lastModified is the (local file) "modified timestamp" of an/each underlying artifact.


In particular for the interval:x setting:

  • the colon : is not that strict - any "non-empty" character could do it (=, , ...).
  • negative values x < 0 should yield to "never".
  • interval:0 I would assume a "minutely" (0-59 secs. or above...) interval.
  • number format exceptions result in 24 * 60 minutes (~"daily").

..see: DefaultUpdatePolicyAnalyzer, DefaultMetadataResolver#resolveMetadata() and RepositoryPolicy

寒冷纷飞旳雪 2024-10-22 07:29:06

Maven 有 updatePolicy 设置,用于指定检查存储库中的更新或保持存储库与远程同步的频率。

  • updatePolicy 的默认值是每天。
  • 其他值可以是always/never/XX(指定间隔以分钟为单位)。

下面的代码示例可以添加到 Maven 用户设置文件中来配置 updatePolicy。

<pluginRepositories>
    <pluginRepository>
        <id>Releases</id>
        <url>http://<host>:<port>/nexus/content/repositories/releases/</url>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>             
</pluginRepositories>

Maven has updatePolicy settings for specifying the frequency to check the updates in the repository or to keep the repository in sync with remote.

  • The default value for updatePolicy is daily.
  • Other values can be always / never/ XX (specifying interval in minutes).

Below code sample can be added to maven user settings file to configure updatePolicy.

<pluginRepositories>
    <pluginRepository>
        <id>Releases</id>
        <url>http://<host>:<port>/nexus/content/repositories/releases/</url>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>             
</pluginRepositories>
七秒鱼° 2024-10-22 07:29:06

我是如何遇到这个问题的,

当我从 Eclipse Juno 更改为 Luna 并从 SVN 存储库检查我的 Maven 项目时,我在构建应用程序时遇到了同样的问题。

我尝试了什么?
我尝试清理本地存储库,然后使用 -U 选项再次更新所有版本。但我的问题仍然存在。

然后我去了窗口-->首选项->梅文 -->用户设置-->并单击“本地存储库”下的“重新索引”按钮,然后等待重新索引发生。

就这样,问题就解决了。

How I got this problem,

When I changed from Eclipse Juno to Luna, and checkout my maven projects from SVN repo, I got the same issues while building the applications.

What I tried?
I tried clean Local repository and then updating all the versions again using -U option. But my problem continued.

Then I went to Window --> Preferences -> Maven --> User Settings --> and clicked on Reindex button under Local Repository and wait for the reindex to happen.

That's all, the issue is resolved.

老街孤人 2024-10-22 07:29:06

就我而言,解决方案很愚蠢:我只是有不正确的依赖版本。

In my case the solution was stupid: I just had incorrect dependency versions.

不语却知心 2024-10-22 07:29:06

有点相关..我正在

“[错误]无法在项目 testproject 上执行目标:无法解析项目 myjarname:jar:1.0-0 的依赖项:无法在 http://repo1 中找到 myjarname-core:bundle:1.0-0 .maven.org/maven2 已缓存在本地存储库中,直到中心更新间隔已过或强制更新时才会重新尝试解析 -> [帮助 1]"

此错误是由于意外使用 Maven 造成的3 而不是 Maven 2。只是觉得这可能会节省一些人的时间,因为我最初的谷歌搜索将我带到了这个页面。

Somewhat relevent.. I was getting

"[ERROR] Failed to execute goal on project testproject: Could not resolve dependencies for project myjarname:jar:1.0-0: Failure to find myjarname-core:bundle:1.0-0 in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]"

This error was caused by accidentally using Maven 3 instead of Maven 2. Just figured it might save someone some time, because my initial google search led me to this page.

梦回梦里 2024-10-22 07:29:06

我有同样的错误(不会重新尝试解决方案...)但我有不同的要求,因为我的本地存储库中有文件,目前无法远程使用(旧的过时的库和内部库),并且我的公司关系系统已关闭,但它们确实存在于我的 .m2 存储库中。

Maven 仍然拒绝构建,产生与上面相同的错误。

对于有问题的库,我只是删除了相应的文件:

_remote.repositories

示例路径:users\[用户名]\.m2\[有问题的 jar
路径]\[版本号]\_remote.respositories

知道这些文件在本地可用。

注意:长期解决方案,我可能应该启动并运行我们之前的 Nexus 系统,对于那些遗留的 jar,将它们签入项目的 lib 文件夹(或类似的文件夹)下

I had the same error, (resolution will not be reattempted...) but I had different requirements, as I have files in my local repository, that are currently not available remotely (old outdated libraries and internal libraries), and my company nexus system is down, but they do exist in my .m2 repos.

Maven still refused to build, producing the same error above.

For the offending libraries, I just removed the corresponding file:

_remote.repositories

exmple path: users\[username]\.m2\[offending jar
path]\[versionnumber]\_remote.respositories

knowing that these files are only available locally.

Note: Long term resolution, I should probably get our previous nexus system up and running, and for those jars that are legacy, check them into the project under a lib folder (or something like that)

雄赳赳气昂昂 2024-10-22 07:29:06

我已经解决了!

我之前遇到过这个问题,在查看了一些评论后发现它有效。
我们只需更正 {m2_home}/.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>.m2/repository</localRepository>
    <profiles>
        <profile>
          <repositories>
            <repository>
              <id>projectid</id>
              <url>http://localhost</url>
              <name>Project name</name>
              <releases>
                <enabled>false</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
              </releases>
             </repository>
          </repositories>
        </profile>
      </profiles>
    </settings>

并执行 maven clean install 命令。

**/maven_home/mvn -f project_directory/pom.xml -DskipTests clean install**

I have resolved it!

I have encountered this issue earlier and after reviewing some comments it worked.
we only have to correct settings.xml file under {m2_home}/.m2

    <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>.m2/repository</localRepository>
    <profiles>
        <profile>
          <repositories>
            <repository>
              <id>projectid</id>
              <url>http://localhost</url>
              <name>Project name</name>
              <releases>
                <enabled>false</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
              </releases>
             </repository>
          </repositories>
        </profile>
      </profiles>
    </settings>

and execute maven clean install command.

**/maven_home/mvn -f project_directory/pom.xml -DskipTests clean install**
半世蒼涼 2024-10-22 07:29:06

我遇到了这个问题, this 中提出的全面描述帮助我解决了这个问题。

第二个声明的问题是我的问题。我使用了一个第三方存储库,我刚刚将其添加到我的项目中的 pom 文件的 repository 部分。我将相同的存储库信息添加到 pluginrepository 中来解决此问题。

I had this problem and the comprehensive descriptions proposed in this helped me to fix it.

The second declared problem was my issue. I used a third-party repository which I had just added it do the repository part of the pom file in my project. I add the same repository information into pluginrepository to resolve this problem.

新人笑 2024-10-22 07:29:06

我在我的私人存储库上上传的第三方库遇到了同样的问题。有时所描述的修复对我有用,但有时却不起作用。

我认为问题的根本原因是工件缺少 pom.xml 文件。 (第三方工件的 pom.xml 不是项目中的 pom.xml)。我假设 Maven 期望每个工件都有一个 pom.xml,因此它可以解决所有工件的依赖关系。有时它可以在没有 pom.xml 的情况下工作,但有时却不能(我还没有确定,当它不能时)。

我使用 Nexus3 作为私人存储库。上传工件时,您可以选中一个选项来为工件生成 pom.xml 文件。

I ran into the same problems with uploaded third party libraries on my private repository. Sometimes the described fixes worked for me, but sometimes they did not.

I think the root cause of the problem is a missing pom.xml file for the artifact. (The pom.xml for the third party artifact not your pom.xml in your project). I assume Maven expects for every artifact a pom.xml, so it can resolve the dependencies for all artifacts. Sometimes it works without a pom.xml, but sometimes it does not (I have not identified, when it does not).

I use Nexus3 as a private repository. When you upload an artifact, you can check an option to generate a pom.xml file for the artifact.

草莓酥 2024-10-22 07:29:06

更改我的 settings.xml 中的 localRepository 路径解决了该问题

Changing the localRepository path in my settings.xml solved the issue

半步萧音过轻尘 2024-10-22 07:29:06

我已经尝试了以下解决方案,但没有一个对我有用(使用 eclipse 嵌入的 maven):

  • 从存储库文件夹中删除文件
  • 在 settings.xml 中添加镜像
  • 在 settings.xml 中添加带有 updatePolicy=always 的配置文件

我见过很多这样的解决方案解决方案有很多赞成票,但它们已经很旧了,所以我猜它们曾经工作过一次,但现在不再有效(至少对于嵌入 eclipse 的 maven 来说)。

什么对我有用:

在 Eclipse 中转到 Window >首选项> Maven 并将“全局更新策略”字段设置为“始终”。

I have tried the following solutions but none worked for me (with eclipse-embedded maven):

  • deleting files from the repository folder
  • adding a mirror in settings.xml
  • adding a profile with updatePolicy=always in settings.xml

I've seen many of these solution with lot of upvotes, but they are pretty old, so I guess they worked once, but nowdays are no longer valid (at least for eclipse-embedded maven).

What worked for me:

in Eclipse go to Window > Preferences > Maven and set the "Global Update Policy" field to "Always".

岁月蹉跎了容颜 2024-10-22 07:29:06

转到您的 Pom 文件,右键单击并向下滚动,然后单击 maven 打开 settings.xml 文件(如您从图像中看到的)并添加以下代码(到您的 settings.xml 文件),然后保存并关闭并等待让maven重新加载。

<mirrors>
  <mirror>
    <id>my-mirror</id>
    <url>https://repo.maven.apache.org/maven2/</url>
    <mirrorOf>central</mirrorOf>
  </mirror>
</mirrors>

然后刷新/重新加载您的 pom 文件/项目。

N:B 您可能必须转到您的主 Spring Boot 类和 @SprinBootApplication 之上的 Hoover,然后单击建议添加 Maven 依赖项......

这将重新安装您可能丢失的本地 Maven 依赖项。

输入图片此处描述

Go to your Pom file and right-click and scroll down then click on maven to open the settings.xml file (as you see from the image) and add the following code (to your settings.xml file) then save and close and wait for maven to reload.

<mirrors>
  <mirror>
    <id>my-mirror</id>
    <url>https://repo.maven.apache.org/maven2/</url>
    <mirrorOf>central</mirrorOf>
  </mirror>
</mirrors>

Then refresh/reload your pom file/project.

N:B You may have to go to your main spring boot class and Hoover on top of @SprinBootApplication then click on the suggestion to add Maven dependency ......

This will reinstall your local maven dependencies which you are likely to have lost.

enter image description here

风吹过旳痕迹 2024-10-22 07:29:06

确保您正在寻找的工件存在(如果它在您的本地项目运行中):
光盘 ..
光盘项目名称
mvn clean install

然后你就会在本地拥有它。

为了更好的练习,请执行以下操作:
mvn clean deploy 这样你就可以再次使用它而不会出现这个问题

Make sure that the artifact you are looking for is exist , if its on your local project run :
cd ..
cd project name
mvn clean install

Then you will have it locally.

for better practice do :
mvn clean deploy so you can use it again without this problem

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文