如何在 Netbeans 中创建 Java 项目,而不使用 Maven 作为默认值? [英] How to create Java project in Netbeans, without using Maven as default?

查看:43
本文介绍了如何在 Netbeans 中创建 Java 项目,而不使用 Maven 作为默认值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试创建一个基本的 Java 项目.出现的第一个选项是Java with Maven",我已经使用过它,但没有提供我需要的创建主类"选项.

我使用的是 Apache Netbeans IDE 11.0,在 Windows 10、x64 上运行.我已经给了它一整天的时间,更新并安装了我找到的最新 JDK 版本,但仍然无法使其正常工作.

我也读过这个答案,但它不起作用:

感谢任何帮助,谢谢.

解决方案

项目模板在 Apache NetBeans 11.0 中进行了修订,以使 Maven 项目更加突出.来自

<块引用>

有了上述内容,人们就不太可能简单地去不再存在的 Java 类别,然后最终得到一个基于 Ant 的类别项目,不用考虑.默认情况下,Apache 的用户现在鼓励 NetBeans 考虑 Apache Maven 和 Apache Gradle第一的.旧的Ant相关类还在,以免完全混淆任何人,只是在较低级别的Java 上面也解决了关于Java EE"的讨论,即,这里的想法,来自讨论,是将类别命名为Java企业".

在启动时,所有类别都关闭,即没有一个更突出最初比任何其他.

一个可能的反对意见是,如果您是一个完整的 Java 新手,你不会知道 Maven、Gradle 或 Ant 是什么.嗯,一直都是这样情况就是如此,NetBeans 人为地隐藏了该选择有一个简单地命名为Java"的类别,然后导致每个人结束了基于 Ant 的项目. 扭转这一局面并拥有一个导致基于 Maven 的项目的简单命名为Java"的类别是也可能不正确,即需要谨慎平衡.

因此,如果您在早期版本的 NetBeans 中使用 File > New Project... > Java > Java Application 创建了一个项目,则应该使用 File > New Project... > Java在 NetBeans 11.0 中使用 Ant > Java 应用程序.

注意事项:

  • NetBeans 错误报告 NETBEANS-2040 Maven First in New Project Wizard 指的是.
  • 另请参阅此 YouTube 视频开头的讨论Apache NetBeans 11.0 粗略指南.
  • NetBeans 11.0 中的其他项目向导更改:
    • 在 NetBeans 11.0 中,我必须安装 Gradle 插件(工具 > 插件 > 可用插件 > Gradle)才能在项目向导中看到 Java with Gradle.
    • 在早期版本的 NetBeans 中,您使用 File > New Project... > Java EE > ... 创建了一个 Java Enterprise 项目,但在 NetBeans 11.0 中,这已更改为 File >新建项目...> Java with Ant > Java Enterprise > ...

I'm currently trying to create a basic Java project. The first option that appears is "Java with Maven", which I already used, but isn't giving me the "Create Main Class" option that I need.

I'm using Apache Netbeans IDE 11.0, running on Windows 10, x64. I've given it a whole day, updating and installing the most recent JDK versions I found, and still I'm unable to make it work.

I've also read this answer, but it's not working: Can't create project on Netbeans 8.2

Here's an image of what I'm getting:

Any help is appreciated, thanks.

解决方案

The project templates were revised in Apache NetBeans 11.0 to give Maven projects greater prominence. From an Apache NetBeans blog post:

Restructuring of Project Templates in Apache NetBeans

There's been lots of discussion in the Apache NetBeans community about how best to express the fact that Apache Maven and Apache Gradle are more modern choices to be aware of than Apache Ant, while at the same time not implying that there's anything wrong with using Apache Ant.

Here's what we seem to have reached consensus around, i.e., move all Ant-based project templates into a separate Ant-specific folder, while putting the other two build systems higher and therefore more prominently in the list:

With the above, someone is less likely to simply go to the no-longer-existing Java category and then end up with an Ant-based project, without thinking about it. By default, the user of Apache NetBeans is now encouraged to consider Apache Maven and Apache Gradle first. The old Ant-related categories are still there, so as not to confuse anyone completely, just structured within a lower ranked "Java with Ant" category. The above also solves the discussion re "Java EE", i.e., here the idea, from discussions, is to name the category "Java Enterprise".

At startup, all categories are closed, i.e., none is more prominent initially than any other.

An objection one could have is that, if you're a complete Java newbie, you won't know what Maven, Gradle, or Ant are. Well, that has always been the case and NetBeans has artificially hidden that choice by having a category simply named "Java", which then resulted in everyone ending up with Ant-based projects. To turn that around and have a category simply named "Java" that results in Maven-based projects is probably not right either, i.e., a careful balance needs to be struck.

So if you created a project using File > New Project... > Java > Java Application in earlier releases of NetBeans, you should use File > New Project... > Java with Ant > Java Application in NetBeans 11.0.

Notes:

  • NetBeans Bug Report NETBEANS-2040 Maven First in New Project Wizard refers.
  • Also see the discussion at the start of this YouTube video The Rough Guide to Apache NetBeans 11.0.
  • Other project wizard changes in NetBeans 11.0:
    • In NetBeans 11.0 I had to install the Gradle plugin (Tools > Plugins > Available Plugins > Gradle) in order to see Java with Gradle in the Project Wizard.
    • In earlier releases of NetBeans you created a Java Enterprise project using File > New Project... > Java EE > ..., but in NetBeans 11.0 this has changed to File > New Project... > Java with Ant > Java Enterprise > ...

这篇关于如何在 Netbeans 中创建 Java 项目,而不使用 Maven 作为默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆