如何指示maven-ejb-plugin仅在客户端EJB包中包括必需的类? [英] How to instruct maven-ejb-plugin to only include required classes in client EJB package?

查看:83
本文介绍了如何指示maven-ejb-plugin仅在客户端EJB包中包括必需的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当大的旧版模块,其中既包含EJB 3.0,又包含一些业务逻辑类.我正在尝试将构建过程转换为使用Maven,并且在配置maven-ejb-plugin时遇到困难.

I have a fairly large legacy module which contains both EJB 3.0 and some business logic classes. I am trying to convert the build process to use maven and am having difficulty configuring the maven-ejb-plugin.

我正在尝试使用maven-ejb-plugin生成客户端EJB包,但是请注意,客户端包也包含所有业务逻辑类-即使EJB未引用它们.

I'm trying to generate the client EJB package using the maven-ejb-plugin, but notice that the client package contains all the business logic classes as well - even if they are not referenced by the EJBs.

我当前的配置是: org.apache.maven.plugins maven-ejb-插件 默认ejb $ {project.build.outputDirectory} j 3.0 真的

My current configuration is: org.apache.maven.plugins maven-ejb-plugin default-ejb ${project.build.outputDirectory} ejb 3.0 true

不幸的是,业务类/模型/DTO的包之间没有非常清晰的分隔,因此要准确地确定哪些EJB依赖于哪些类并不容易.

Unfortunately, there is not a very clear separation of packages for business classes/models/DTOs so it is a not easy to pinpoint exactly which EJBs depend on which classes.

maven-ejb-plugin中是否存在一种机制来指示maven仅包括require EJB接口/实现&客户端程序包中的依赖类,并忽略/跳过其他所有内容?还是我必须手动准确地找出各个接口所需的依赖类,然后将插件配置为仅包含那些文件?

Is there a mechanism in the maven-ejb-plugin to instruct maven to only include the require EJB interfaces/implementations & dependent classes in the client package and ignore/skip everything else? Or do I have to manually figure out exactly what dependent classes are required by the individual interfaces and configure the plugin to only include those files?

推荐答案

据我了解,您有一些软件包,包括例如远程或本地EJB的接口,并且在其中定义了(无状态statefull,mdb等).相同的接口包,并且您只想导入客户端所需的类(或接口),出于逻辑原因,它不需要实现.

As I understand you have some packages including for example the interfaces of your remote or local EJB, and you have the definition (stateless statefull, mdb, whatever) in the same package of your interfaces, and you want to import only the classes (or interfaces) that your client needs, it does not need the implementantion for logic reasons.

好,这里有两点,作为建议,您至少应该在一个单独的项目中具有远程或本地接口以将其解耦(作为Maven项目),并且每个想要使用它们的人都必须将其作为依赖项导入,无需了解其实现方式.

Well, we have two points here, as recomendation you should have at least your remotes or local interfaces in a separate project to decouple this (as Maven project) and everyone who wants to use them just have to import it as dependency, with no need to know about their implementation.

另一点是,如果您遵循一些命名约定,则可以通过包含(或排除).java类来实现所需的功能.

The other point is if you have follow some naming conventions maybe you could acomplish whan you want by including (or excluding) .java class with some patter.

您可以检查上面的链接:

You can check the link above:

http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html

如果您使用类似以下的约定: http://www.oracle.com/technetwork/java/namingconventions-139351.html

If you use some conventions like these: http://www.oracle.com/technetwork/java/namingconventions-139351.html

例如,您将能够:

<plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <configuration>
          <excludes>
            <include>**/Local*.java</include>
          </excludes>
        </configuration>
      </plugin>
    </plugins>

这篇关于如何指示maven-ejb-plugin仅在客户端EJB包中包括必需的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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