简体   繁体   中英

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:

在此处输入图片说明

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? Any advice would be appreciated

在此处输入图片说明

tl;dr

Don't.

Do not configure libraries manually for your Vaadin project.

Instead, create a new Vaadin project using the template of a Maven archetype provided by the Vaadin Ltd company. Locate and edit the new project's POM.xml file to list the libraries you need Maven to automatically download and install.

For Vaadin Framework (Vaadin 8), see:

Maven

Usually Vaadin projects are configured using the Apache Maven tool.

Maven is quite popular across all kinds of Java projects. All three major IDEs (NetBeans, IntelliJ, Eclipse) support Maven-driven projects as an alternative to their own particular project definition system.

Maven has two purposes:

  • 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).
  • Manage “dependencies” . This means you tell Maven what libraries your project needs. Maven then reaches out over the Internet to access a Maven-oriented repository of known libraries. Maven downloads your needed library from that repository, placing it in an appropriate place within your project. 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.

You specify both the project-build configuration and your list of desired libraries (“dependencies”) in one or more POM.xml files.

Using Maven eliminates the need to place libraries manually as you are attempting to do. No need to touch the NetBeans Library Manager . Indeed, I believe manually configuring libraries will conflict with Maven, with troubled results.

Using Maven is annoying at first, having to learn the lingo and the concepts. But once you are orientated, Maven does save you time and trouble, and makes your developer life easier. 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.

I recommend you take a few hours to learn the basics. You'll find many introductions and tutorials on Maven.

The Vaadin Ltd company provides a few good Maven archetypes for a new Vaadin project.

  • vaadin-archetype-application
    One is a simpler structure, good for learning Vaadin and also good if building a simple small app.
  • vaadin-archetype-application-multimodule
    Another archetype is a “multi-module” Maven archetype, good for more serious Vaadin apps. 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).

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. Such a plug-in is no longer needed, now supplanted by Maven. You can ignore old outmoded guides to Vaadin that talk about an IDE plug-in for Vaadin.

Note: This entire Answer applies to Vaadin 8 ( Vaadin Framework ) specifically, and probably Vaadin 7 (as I recall). Vaadin 10 ( Vaadin Flow ) is a new ballgame, and I am not yet familiar with the situation there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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