简体   繁体   English

将库添加到Netbeans中的Vaadin Web App项目

[英]Add library to Vaadin Web App project in Netbeans

I recently used the Library Manager in Netbeans (8.2, on Windows 10) to add a library, as show below: 我最近在Netbeans(在Windows 10上为8.2)中使用了图书馆管理器来添加一个图书馆,如下所示:

在此处输入图片说明

However, in most guides I find online, in order to actually add the library to the project, I should do the following: 但是,在我在线上找到的大多数指南中,为了将库实际添加到项目中,我应该执行以下操作:

Right click the project -> Select the Libraries tab -> .... further steps .... However, I haven't even been able to make it past the second step: the Libraries tab simply does not exist on my project properties, as seen below: Is this because the structure for a Vaadin web app project is so different from other Netbeans projects? 右键单击项目->选择“库”选项卡-> ....进一步的步骤....但是,我什至无法通过第二步:“库”选项卡在我的项目属性中根本不存在,如下所示:这是因为Vaadin Web应用程序项目的结构与其他Netbeans项目有很大不同吗? Any advice would be appreciated 任何意见,将不胜感激

在此处输入图片说明

tl;dr TL;博士

Don't. 别。

Do not configure libraries manually for your Vaadin project. 不要为您的Vaadin项目手动配置库。

Instead, create a new Vaadin project using the template of a Maven archetype provided by the Vaadin Ltd company. 而是使用Vaadin Ltd公司提供的Maven 原型模板创建一个新的Vaadin项目。 Locate and edit the new project's POM.xml file to list the libraries you need Maven to automatically download and install. 找到并编辑新项目的POM.xml文件,以列出您需要Maven自动下载和安装的库。

For Vaadin Framework (Vaadin 8), see: 有关Vaadin框架(Vaadin 8),请参阅:

Maven Maven的

Usually Vaadin projects are configured using the Apache Maven tool. 通常,Vaadin项目是使用Apache Maven工具配置的。

Maven is quite popular across all kinds of Java projects. Maven在各种Java项目中都非常流行。 All three major IDEs (NetBeans, IntelliJ, Eclipse) support Maven-driven projects as an alternative to their own particular project definition system. 所有三个主要的IDE(NetBeans,IntelliJ,Eclipse)都支持Maven驱动的项目,以替代其自己的特定项目定义系统。

Maven has two purposes: Maven有两个目的:

  • Configure the project parts and define a series of events for the compile-and-build process . 配置项目部分,并为编译和构建过程定义一系列事件。 You can create a new project pre-configured this way by starting with a Maven archetype (a project template). 您可以通过从Maven 原型 (项目模板)开始创建以这种方式预先配置的新项目。
  • Manage “dependencies” . 管理“依赖关系” This means you tell Maven what libraries your project needs. 这意味着您可以告诉Maven项目需要哪些库。 Maven then reaches out over the Internet to access a Maven-oriented repository of known libraries. 然后,Maven通过Internet进行访问,以访问已知库的面向Maven的存储库。 Maven downloads your needed library from that repository, placing it in an appropriate place within your project. Maven从该存储库下载所需的库,并将其放置在项目中的适当位置。 Tip: Be patient the first time you do this as Maven builds a local cache of the repository's database, taking several minutes or more. 提示:第一次进行此操作时要耐心,因为Maven会建立存储库数据库的本地缓存,这需要花费几分钟或更长时间。

You specify both the project-build configuration and your list of desired libraries (“dependencies”) in one or more POM.xml files. 您可以在一个或多个POM.xml文件中同时指定项目构建配置和所需库(“依赖关系”)列表。

Using Maven eliminates the need to place libraries manually as you are attempting to do. 使用Maven无需在尝试进行操作时手动放置库。 No need to touch the NetBeans Library Manager . 无需触摸NetBeans 库管理器 Indeed, I believe manually configuring libraries will conflict with Maven, with troubled results. 确实,我相信手动配置库将与Maven冲突,从而产生麻烦的结果。

Using Maven is annoying at first, having to learn the lingo and the concepts. 刚开始使用Maven很烦,必须学习术语和概念。 But once you are orientated, Maven does save you time and trouble, and makes your developer life easier. 但是一旦您适应了Maven,Maven确实可以节省您的时间和麻烦,并使您的开发人员生活更轻松。 One big benefit: Maven makes switching between the 3 main IDEs much easier since you don't have to learn about each one's own idiosyncratic project-build-system. 一个很大的好处:Maven使得在3个主要IDE之间的切换变得更加容易,因为您不必了解每个人自己的特有项目构建系统。

I recommend you take a few hours to learn the basics. 我建议您花一些时间来学习基础知识。 You'll find many introductions and tutorials on Maven. 您会在Maven上找到许多介绍和教程。

The Vaadin Ltd company provides a few good Maven archetypes for a new Vaadin project. Vaadin Ltd公司为新的Vaadin项目提供了一些很好的Maven原型

  • vaadin-archetype-application
    One is a simpler structure, good for learning Vaadin and also good if building a simple small app. 一种是更简单的结构,既适合学习Vaadin,也适合构建简单的小型应用程序。
  • vaadin-archetype-application-multimodule
    Another archetype is a “multi-module” Maven archetype, good for more serious Vaadin apps. 另一个原型是“多模块” Maven原型,适用于更严肃的Vaadin应用程序。 One major feature is that your backend logic such as database-access can be separated from your user-interface logic, each in separate modules. 一个主要功能是可以将您的后端逻辑(例如数据库访问)与用户界面逻辑分开,每个逻辑都在单独的模块中。 You should definitely start with the simple archetype first. 您绝对应该首先从简单原型开始。 Don't touch the multi-module archetype until you are comfortable with both Vaadin and Maven (unless you have the guidance of a helpful colleague who is a Maven maven). 除非您对Vaadin和Maven都感到满意,否则请不要触摸多模块原型(除非您有Maven专家的有用同事的指导)。

By the way, Vaadin development in previous years virtually required the use of a Vaadin-savvy plugin that you would have to install into your IDE. 顺便说一句,前几年Vaadin的开发实际上需要使用精通Vaadin的插件,您必须将其安装到IDE中。 Such a plug-in is no longer needed, now supplanted by Maven. 不再需要这种插件,现在已被Maven取代。 You can ignore old outmoded guides to Vaadin that talk about an IDE plug-in for Vaadin. 您可以忽略有关Vaadin的过时过时的指南,这些指南谈论了Vaadin的IDE插件。

Note: This entire Answer applies to Vaadin 8 ( Vaadin Framework ) specifically, and probably Vaadin 7 (as I recall). 注意:整个答案特别适用于Vaadin 8( Vaadin Framework ),也可能适用于Vaadin 7(我记得)。 Vaadin 10 ( Vaadin Flow ) is a new ballgame, and I am not yet familiar with the situation there. Vaadin 10( Vaadin Flow )是一个新的球类游戏,我对那里的情况还不熟悉。

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

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