可卸载的 Netbeans 项目(pom 在本地存储库中不可用)

发布于 2024-12-28 16:51:18 字数 1684 浏览 3 评论 0 原文

我有一个 Maven 项目,在 Netbeans 中一直运行良好,但从 6.9 升级到 7.1 并不顺利。我收到以下错误:

为 foo.bar:baz:1.0.0 构建有效模型时遇到 1 个问题 [致命] 不可解析的父 POM:存储库系统已脱机,但工件 foo:bar-parent:pom:1.0.1 在本地存储库中不可用。和 'parent.relativePath' 指向错误的本地 POM @ 第 12 行,第 13 列 对于位于 /Users/me/workspace/pom.xml 的项目 foo.bar:baz:1.0.0

我发现这个 错误单很好地描述了另一个人的问题,但使用“重新加载 POM”的建议不起作用,也不起作用mvn 验证

这里有几个令人困惑的项目。

  • 在命令行上运行有效。
  • 我的同事使用相同的(从所有迹象来看)设置,在 NB 7.1 上运行这个项目。
  • 在 Netbeans 内构建有效(构建成功)
  • 使用错误对话框上提供的“Prime Build”按钮启动成功的构建。
  • 文件没有丢失!它现在(并且已经)在本地仓库中!正是我所期望的: .m2/repository/foo/bar-parent/1.0.1/bar-parent-1.0.1.pom

根据 Maven POM 介绍 页面,当您有一个父 pom/项目位于与正常位置不同的位置(其中“正常”是“../pom.xml”)。

就我而言,我的父项目实际上只是一个 pom,除了存储库(本地和远程)之外,它不存在于任何地方。即使它在本地不存在,我也希望进行二次“在线”构建(按照建议)可以修复 Netbeans,但事实并非如此。

有一次,我在 Netbeans 之外手动更改了我的 pom 文件,而 NB 内的项目自行修复。我以相同的方式手动修改了子项目以使它们正常工作,但修复并没有持续。几分钟后,“[unloadable]”绰号又回来了,尽管我不知道确切的时间或原因导致它回来。

我尝试使用 Bundled v3.0.3 Maven、外部 v3.0.2 Maven、删除我的 ~/.netbeans* 文件夹、删除我的 .m2/repository 文件夹,将 他的 .m2/repository 复制到我的计算机,删除所有版本的 Netbeans 并重新安装 7.1,关闭并重新打开项目和应用程序,让Netbeans 使用正常的 BuildClean and Build 选项以及错误对话框中的 Prime Build 选项从头开始构建项目,执行以下操作在命令行上从头开始构建,然后导入到 Netbeans,及其任何和所有组合,似乎没有什么重要的。

现在我正在降级到 6.9.1,但我很想知道是否还有其他方法可以尝试让这项工作正常进行。

I have a Maven project that has always worked fine in Netbeans, but upgrading from 6.9 to 7.1 did not go well. I get the following error:

1 problem was encountered while building the effective model for foo.bar:baz:1.0.0
[FATAL] Non-resolvable parent POM: The repository system is offline but the artifact foo:bar-parent:pom:1.0.1 is not available in the local repository. and 'parent.relativePath' points at wrong local POM @ line 12, column 13
for project foo.bar:baz:1.0.0 at /Users/me/workspace/pom.xml

I found this bug ticket for Netbeans that pretty well describes the issue for another guy but the suggestion of using "Reload POM" doesn't work, nor does mvn validate.

There are several confusing items here.

  • Running on commandline works.
  • My co-worker, with identical (by all indications) setup, runs this project on NB 7.1.
  • Building inside Netbeans works (the build succeeds)
  • Using the provided "Prime Build" button on the error dialog starts a build that succeeds.
  • The file is not missing! It is (and has been) in the local repo! Exactly where I'd expect it: .m2/repository/foo/bar-parent/1.0.1/bar-parent-1.0.1.pom

According to the Maven POM intro page, the relativePath attribute is to be used when you have a parent pom/project located in a different-than-normal location (where "normal" is "../pom.xml").

In my case, my parent project is actually just a pom, and it doesn't live anywhere except in the repository (locally and remotely). Even if it didn't exist locally, I'd expect doing a secondary "online" build (as suggested) would fix Netbeans, but it doesn't.

At one point I manually changed my pom file outside of Netbeans, and the project inside NB fixed itself. I manually modified the subprojects the same way to get them to work but the fix didn't last. A few minutes later the "[unloadable]" moniker returned, though I don't know exactly when or what caused it to return.

I've tried using the Bundled v3.0.3 Maven, my external v3.0.2 Maven, deleting my ~/.netbeans* folders, deleting my .m2/repository folder, copying his .m2/repository to my machine, deleting all versions of Netbeans and reinstalling 7.1, closing and reopening the projects and the app, letting Netbeans build the project from scratch using both the normal Build, Clean and Build options as well as the Prime Build option on the error dialog, doing the build from scratch on the commandline then importing to Netbeans, any and all combinations thereof, and nothing seems to matter.

For now I'm downgrading to 6.9.1, but I would love to know if there's something else I can try to make this work.

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

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

发布评论

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

评论(6

她比我温柔 2025-01-04 16:51:18

你的 pom.xml 的标头是什么?我已将其更改为:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

Maven CLI 构建它们,NetBeans 6.x 也构建...但 NetBeans 7.x 仅构建第一个。

What is the header of your pom.xml? I've changed it to this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

from

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

Maven CLI builds both of them, NetBeans 6.x too... but NetBeans 7.x builds only the first one.

獨角戲 2025-01-04 16:51:18

更新:我也设置了我的settings.xml...:(

<mirrors>
  <mirror>
    <id>javaforum</id>
    <url>http://nexus.javaforum.hu/nexus/content/groups/public/</url>
    <mirrorOf>*</mirrorOf>
  </mirror>
</mirrors>
<profiles>
  <profile>
    <id>default</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <repositories>
      <repository>
        <id>javaforum</id>
        <url>http://nexus.javaforum.hu/nexus/content/groups/public/</url>
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
        </snapshots>
      </repository>
    </repositories>
  </profile>
</profiles>

它现在适用于NetBeans 7.x。

如果我删除/注释“存储库”部分:

* CLI (3.0.3) build is working
* NetBeans 7.x build is working but the project is "unloadable"

如果我删除/注释“镜像”部分:

* CLI (3.0-3) build isn't working
* NetBeans 7.x build is working, the project looks like good

所以, pom.xml 修改是不必要的恕我直言...:)

Update: I've set my settings.xml too... :(

<mirrors>
  <mirror>
    <id>javaforum</id>
    <url>http://nexus.javaforum.hu/nexus/content/groups/public/</url>
    <mirrorOf>*</mirrorOf>
  </mirror>
</mirrors>
<profiles>
  <profile>
    <id>default</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <repositories>
      <repository>
        <id>javaforum</id>
        <url>http://nexus.javaforum.hu/nexus/content/groups/public/</url>
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>true</enabled>
        </snapshots>
      </repository>
    </repositories>
  </profile>
</profiles>

It works now with NetBeans 7.x.

If I remove/comment the "repository" section:

* CLI (3.0.3) build is working
* NetBeans 7.x build is working but the project is "unloadable"

If I remove/comment the "mirror" section:

* CLI (3.0-3) build isn't working
* NetBeans 7.x build is working, the project looks like good

So, the pom.xml modification is not necessary IMHO... :)

捶死心动 2025-01-04 16:51:18

我最终不得不将 pom.xml 文件从我的存储库复制到项目 pom.xml 上方的一个目录级别,然后重命名为 pom.xml。不理想,但它有效。

I wound up having to copy the pom.xml file from my repo to one directory level above my project's pom.xml and renaming to pom.xml. Not ideal but it worked.

找个人就嫁了吧 2025-01-04 16:51:18

在尝试清理我的内部存储库(Archiva,使用存储库组)、简化我的 settings.xml,然后将父 POM 添加到我的项目后,我在运行 NetBeans 7.1.x 时看到了所描述的错误。

如果我删除项目中的父 POM 引用,问题就会消失。

如果我在 settings.xml 中包含有效的存储库部分的活动配置文件,问题就会消失。

如果我在项目 POM 中包含有效的存储库部分,问题就会消失。

我的父 POM 不是多模块项目的根。它只是像任何其他依赖项一样从存储库中提取。我没有可以尝试的带有父级的多模块项目。

不管怎样,maven 可以从命令行很好地构建和部署我的项目,无需进行该设置(即使有父 POM),但 NetBeans 本身似乎需要在某处定义一个存储库部分。

在我看来,Netbeans 处理子项目的方式存在一个错误。我的猜测是,它正在查找父级的默认位置(../pom.xml),当找不到它时,会尝试在定义的存储库中查找它。因为它没有被定义,所以它令人窒息。

当尝试查找父 POM 时,Netbeans 似乎忽略了镜像设置。

I saw the described error when running NetBeans 7.1.x after an attempt to clean up my internal repository (Archiva, using repo groups), simplify my settings.xml and then adding a parent POM to my project.

If I remove the parent POM reference in my project, the issue goes away.

If I include an active profile in my settings.xml with a valid repository section, the issue goes away.

If I include a valid repositories section in my project POM, the issue goes away.

My parent POM is not the root of a multi-module project. It is merely pulled from the repository like any other dependency. I don't have a multi-module project with a parent that I can try it with.

Regardless, maven builds and deploys my projects just fine from the command-line without that setting (even with a parent POM), but NetBeans itself seems to need a repositories section defined somewhere.

Seems to me to be a bug with how Netbeans treats child projects. My guess is that it is looking in the default location location for the parent (../pom.xml) and when it can't find it, tries to look for it in the defined repositories. Since it isn't define, it chokes.

Netbeans seems to ignore the mirrors setting when trying to find the parent POM.

扛起拖把扫天下 2025-01-04 16:51:18

我将父版本从 2.6.5 更改为 2.6.4

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.6.4</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

I changed parent version to 2.6.4 from 2.6.5

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.6.4</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
可爱咩 2025-01-04 16:51:18

就我而言,没有为子项目定义relativePath,而且 Netbeans 14 本身似乎无法推迟默认值。运行 Maven 本身成功,但项目在 Netbeans 中显示为“无法加载” - 我必须对 relativePath 的默认值进行硬编码,以便 Netbeans 正确加载项目 ( ; 也可以工作 - 但正如其他人指出的那样,它应该有效地禁用父 POM 的相对查找,尝试通过本地 Maven 存储库解析它):

   <parent>
      <groupId>org.example</groupId>
      <artifactId>example</artifactId>
      <version>1.0-SNAPSHOT</version>
      <relativePath>../pom.xml</relativePath>
   </parent>

In my case, relativePath was not defined for child projects and it seems that Netbeans 14 itself wasn't able to defer the default value. Running Maven itself was successful, but the projects were shown as "Unloadable" in Netbeans - I had to hardcode the default value of relativePath for the projects to get loaded correctly by Netbeans (<relativePath></relativePath> also works - but as others have pointed out, it is supposed to effectively disable the relative lookup of the parent POM, trying to resolve it through the local Maven repository):

   <parent>
      <groupId>org.example</groupId>
      <artifactId>example</artifactId>
      <version>1.0-SNAPSHOT</version>
      <relativePath>../pom.xml</relativePath>
   </parent>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文