Java Maven 2 & 打包 ejb 与 jar

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18866566/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 11:45:54  来源:igfitidea点击:

Maven 2 & Packaging ejb vs jar

javamaven-2ejb-3.1

提问by tweetysat

If i'm working with ejb 3.1, what's the différence between

如果我正在使用 ejb 3.1,它们之间的区别是什么

<packaging>jar</packaging>

and

<packaging>ejb</packaging>
...
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ejb-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <ejbVersion>3.1</ejbVersion>
    </configuration>
</plugin>

采纳答案by jay

As mentioned at http://maven.apache.org/plugins/maven-ejb-plugin/usage.html,

http://maven.apache.org/plugins/maven-ejb-plugin/usage.html 所述

"The plugin doesn't do any EJB specific processing during the generation of the jar except for validating the existence of an EJB deployment descriptor if the EJB version is 2.0+ "

“如果 EJB 版本为 2.0+,除了验证 EJB 部署描述符的存在之外,该插件在生成 jar 期间不会执行任何 EJB 特定处理”

Since you have ejb 3.1 the ejb-jar.xml file is optional hence unless you want to generate client stubs and utility classes as mentioned in Martin' comments , it won't make much a difference if you use jar packaging .

由于您拥有 ejb 3.1,因此 ejb-jar.xml 文件是可选的,因此除非您想生成 Martin 的评论中提到的客户端存根和实用程序类,否则如果您使用 jar 包装不会有太大区别。

回答by Martin H?ller

Using packaging type ejbincludes the execution of the maven-ejb-plugin. This is not the case for packaging type jar(unless you explicitly configure it). The plugin configuration as stated in the original question is only required if you need to define a configuration that differs from defaults.

使用打包类型ejb包括执行maven-ejb-plugin。包装类型不是这种情况jar(除非您明确配置它)。仅当您需要定义与默认值不同的配置时,才需要原始问题中所述的插件配置。

To my knowledge the main purpose of the maven-ejb-plugin is (was) for creating an EJB clientmodule (only including interfaces). But IMHO this is no longer the recommended way. Usually you provide the APIs via a separate module and do not let the ejb-plugin create it automatically.

据我所知,maven-ejb-plugin 的主要目的是(曾经)用于创建EJB 客户端模块(仅包括接口)。但恕我直言,这不再是推荐的方式。通常,您通过单独的模块提供 API,并且不要让 ejb-plugin 自动创建它。

回答by Sergei Zhylinski

I would also suggest comparing effective pom outputs from maven help plugin for both jarand ejbproject types:

我还建议比较 maven 帮助插件jarejb项目类型的有效 pom 输出:

mvn help:effective-pom

It will allow to compare what maven generates for ejbprojects and for jarprojects.

它将允许比较 maven 为ejb项目和jar项目生成的内容。

The difference between ejband jaralso makes sence when packaging into ear plugin. As a rule, ejbModuleconfiguration property is used for ejb-jars, containing beans, while jarModuleconfiguration property of the ear plugin is used for libraries (jar archives).

之间的区别ejb,并jar包装成穗插件时也使得SENCE。通常,ejbModule配置属性用于包含 bean 的 ejb-jar,而jarModuleear 插件的配置属性用于库(jar 档案)。