Especificar un cliente ejb como dependencia en Maven

I have 2 EJBs A and B (in different jar files), EJB A calls one method of EJB B.

From the following Maven's documents, I use generateClient to create a ejb-client and use ejb-client dependency to get the jar. http://maven.apache.org/plugins/maven-ejb-plugin/examples/generating-ejb-client.html http://people.apache.org/~aramirez/maven-ejb-plugin/examples/ejb-client-dependency.html

It's ok to use Maven to build, deploy and run. The problem is, although project A only needs the interface class of EJB B, but Maven includes all EJB B's dependency libraries into EJB A's dependency. The result is EJB A will have lots of non-necessary jar files. Is there any solution to fix it?

preguntado el 08 de noviembre de 11 a las 10:11

2 Respuestas

I found another solution, Maven's dependency has exclude function and I use it to remove some jar files.

<dependencies>
   <dependency>
       <groupId>com.example</groupId>
       <artifactId>ejb-project</artifactId>
       <version>1.0-SNAPSHOT</version>
       <type>ejb-client</type>      
       <exclusions>
         <exclusion>
           <groupId>sample.ProjectD</groupId>
           <artifactId>Project-D</artifactId>
         </exclusion>
       </exclusions>          
   </dependency>       
</dependencies>

respondido 09 nov., 11:20

Note that in Maven 3, you can exclude all dependencies using a groupId and artifactId of '*'. This may be useful in your scenario. - Haakon

@Haakon In my Eclipse & NetBeans embedded Maven, it shows a warning, saying that using '*' is wrong and it is tolerated by now, but it will be deprecated at some time. - ArturoTena

The only way is to move interface of EJB B to a separate jar. Then use it as dependency in EJBs A and B project/modules.

respondido 08 nov., 11:14

Yes, ejb-client will generate a separated jar for other project to depend - Dennys

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.