简体   繁体   English

Netbeans 使用 pom.xml (Maven) 代替 build.gradle (Gradle)

[英]Netbeans to use pom.xml (Maven) instead of build.gradle (Gradle)

Our team has a Netbeans 11.0 project that (at the root level) contains both a pom.xml file and a build.gradle file.我们的团队有一个 Netbeans 11.0 项目,该项目(在根级别)包含pom.xml文件和build.gradle文件。 When opening the project within Netbeans it assumes it is a Gradle project and treats it as such.在 Netbeans 中打开项目时,它假定它是一个 Gradle 项目并将其视为这样。 However the default should be to open as a Maven project, allowing the pom.xml to take precedence.然而,默认应该作为 Maven 项目打开,允许 pom.xml 优先。

Is there any configuration within Netbeans that will tell it that this is a Maven project (to use the pom.xml file) and treat it as such? Netbeans 中是否有任何配置会告诉它这是一个 Maven 项目(使用 pom.xml 文件)并这样对待它?

(note, if we close the project, temporarily delete the build.gradle file, then re-open in Netbeans, it does open as expected as a Maven project) (注意,如果我们关闭项目,暂时删除 build.gradle 文件,然后在 Netbeans 中重新打开,它确实像 Maven 项目一样打开)

Now on newer versions (using 12 here), in Tools/Options/Java/Gradle exists a checkbox "Prefer Maven Projects over Gradle (needs restart)", check that and you have the solution.现在在较新的版本(此处使用 12)中,在 Tools/Options/Java/Gradle 中存在一个复选框“Prefer Maven Projects over Gradle(需要重新启动)”,检查是否有解决方案。

It seems that Netbeans 11 and newer will consider the project as gradle if both pom.xml and build.gradle files exist in the project.如果 pom.xml 和 ZC19796230423397 项目中同时存在pom.xmlZC19796230423397文件,则 Netbeans 11 和更新版本似乎会将项目视为 gradle

I had the same problem and found no option to tell Netbeans that I want to treat my project as being maven and not gradle.我遇到了同样的问题,但找不到告诉 Netbeans 我想将我的项目视为 maven 而不是 gradle 的选项。

Solution is (as @skomisa commented) to rename build.gradle and settings.gradle to something else like build.gradle_disabled , settings.gradle_disabled and then Netbeans will see your project as maven Solution is (as @skomisa commented) to rename build.gradle and settings.gradle to something else like build.gradle_disabled , settings.gradle_disabled and then Netbeans will see your project as maven

The only way I managed to convince netbeans 11 to use my pom.xml: Close the project, close netbeans.我设法说服 netbeans 11 使用我的 pom.xml 的唯一方法:关闭项目,关闭 netbeans。 Clean up the cache folder (in Linux: ~/.cache/netbeans/11.0) Restart netbeans, reopen the project.清理缓存文件夹(在Linux:~/.cache/netbeans/11.0)重启netbeans,重新打开项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM