Maven - how to create ejb client when packing war

邮差的信 提交于 2019-12-14 03:49:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!