简体   繁体   English

在NetBeans 8的多模块Vaadin项目中,何处添加Maven依赖项?

[英]Where to add Maven dependencies in a multi-module Vaadin project in NetBeans 8?

After creating a new Vaadin 7.6.4 project in NetBeans 8.1 using Vaadin plugin for NetBeans and the provided multi-module archetype with 4 modules , where does one add a dependency for adding libraries? NetBeans 8.1中使用NetBeans的 Vaadin插件和提供的带有4个模块的 多模块 原型NetBeans 8.1中创建新的Vaadin 7.6.4项目之后,在其中添加添加库的依赖项在哪里?

Is the -ui “Dependencies” the right place? -ui “依赖项”在正确的位置吗? Will that be inherited by the -production module? -production模块会继承吗? Or do I need to specify the dependency there too? 还是我也需要在其中指定依赖项? Or anywhere else? 还是其他地方?

I am no Maven maven, not using the Maven command-line. 我不是Maven maven,没有使用Maven命令行。 I am using NetBeans own user-interface, adding dependencies by context-clicking in the Projects panel. 我正在使用NetBeans自己的用户界面,通过在“ Projects面板中单击上下文来添加依赖项。

I'm working on a very similar project. 我正在做一个非常相似的项目。 If you have parent and dependencies, maven inherits these dependencies from child to parent. 如果您有父级和依赖项,则maven将从子级到父级继承这些依赖项。 So refer to each dependency in the base pom of the module that you need it in. An example would be: 因此,请在模块的基础pom中引用所需的每个依赖项。示例如下:

Module A needs dependency Z 模块A需要依赖项Z

Module B needs dependency Y 模块B需要依赖项Y

Module C needs dependency Z and Y 模块C需要依赖项Z和Y

And your modules rely on: 您的模块依赖于:

Parent needs A, B, C 父母需要A,B,C

C needs B C需要B

So in B you would input the dependency of Y, in C you would need the dependency of B and Z, in A you would also need Z. 因此,在B中,您将输入Y的依赖性,在C中,您将需要B和Z的依赖性,在A中,您还将需要Z。

C doesn't need Y declaring as it has inherited it from B C不需要Y声明,因为它已经从B继承了它

The big issues you might get is dealing with cross inheritance, sometimes you need to tell certain modules to exclude some files that are inherited from other jar files, EG old versions of files. 您可能会遇到的大问题是处理交叉继承,有时您需要告诉某些模块以排除从其他jar文件(例如文件的旧版本)继承的某些文件。 You can this by: 您可以通过以下方式实现:

<dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.2.0.Final</version>
        <exclusions>
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

As an example. 举个例子。 Hope that helps a little bit 希望能有所帮助

Yes, this is poorly documented. 是的,这没有充分记录。 Agreed. 同意

Yes, the -ui module is where you do all your work and add your dependencies (except Vaadin Add-ons). 是的, -ui模块是您完成所有工作并添加依赖项的地方(“ Vaadin附加组件”除外)。 The -production module will automatically inherit -ui so you never actually change anything on the production module. -production模块将自动继承-ui因此您实际上不会在生产模块上进行任何更改。

The -widgetset project is where Vaadin Add-on's should be added. -widgetset项目是应添加Vaadin附加组件的位置。 However I don't do that directly, instead I use the Netbeans Vaadin Add-on Browser. 但是,我不直接这样做,而是使用Netbeans Vaadin附加浏览器。 This one you can activate from whatever module in your multi-module project, so even if you activate it on the -ui module it will figure out that you are adding a Vaadin Add-on and will add the dependency to the the POM on the -widgetset project, not the one module you right-clicked on. 您可以从多模块项目中的任何模块激活该模块,因此即使您在-ui模块上将其激活,它也会指出您正在添加Vaadin加载项,并将依赖项添加到POM上的POM中。 -widgetset项目,而不是您右键单击的模块。 Sweet. 甜。

Also there's an annoying bug when you use the multi-module archetype which means that your generated WAR will be really large, for no good reason. 当您使用多模块原型时,还会出现一个令人讨厌的错误,这意味着您生成的WAR会非常大,没有充分的理由。 See https://stackoverflow.com/a/35406389/1504556 . 参见https://stackoverflow.com/a/35406389/1504556 The fix is easy. 修复很容易。

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

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