问题
I've an eclipse base ejb project that I have just converted into a maven module. It is structured in web app layout (as preferred by Tomee). So, in pom.xml, the packaging type is set to war, which maven correctly generated the war file. But I'm not very successful in getting maven to also create a ejb-client jar when packaging the war. I added this to the pom.xml but it does not seems to be doing anything:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>BossClient</id>
<phase>compile</phase>
<configuration>
<ejbVersion>3.1</ejbVersion>
<generateClient>true</generateClient>
<clientIncludes>
<clientInclude>/com/**</clientInclude>
</clientIncludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Any idea how I can get maven to generate the ejb-client when packaging the war?
回答1:
The configuration of maven-ejb-plugin can be simplified like this:
<project>
<groupId>..</groupId>
<artifactId>..</artifactId>
<packaging>ejb</packagin>
<build>
<pluginManagement>
<plugins>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<ejbVersion>3.1</ejbVersion>
<generateClient>true</generateClient>
<clientIncludes>
<clientInclude>/com/**</clientInclude>
</clientIncludes>
</configuration>
</plugins>
<pluginManagement>
</build>
..
</project>
Based on the default life cycle binding there is no need to make an execution block cause maven-ejb-plugin is already part of the life cycle. So only need to align the configuration to your needs.
Furthermore you should think about making a separate module which contains the ejb part and you shouldn't combine war and ejb part together in a single module.
回答2:
I was able to get it to work after removing the phase and adding the goal of ejb to the maven-ejb-plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>BossClient</id>
<configuration>
<ejbVersion>3.1</ejbVersion>
<generateClient>true</generateClient>
<clientIncludes>
<clientInclude>/com/**</clientInclude>
</clientIncludes>
</configuration>
<goals>
<goal>ejb</goal>
</goals>
</execution>
</executions>
</plugin>
来源:https://stackoverflow.com/questions/31439266/maven-how-to-create-ejb-client-when-packing-war