如何使用maven发布本地和远程ejb api

时间:2012-06-30 06:34:08

标签: maven ejb

我有一个无状态会话bean的ejb。我有从每个bean访问的接口或从另一台机器的另一个ejb远程调用。在invy中,我记得我们正在使用类似:publish-remote,publish-api。可以用maven完成同样的事情吗?

将接口发布到一个单独的jar中,以包含在另一个项目中。

谢谢,
czetsuya

2 个答案:

答案 0 :(得分:6)

Maven能够使用maven-ejb-plugin自行生成您的客户端jar:http://maven.apache.org/plugins/maven-ejb-plugin/index.html

<build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ejb-plugin</artifactId>
        <version>2.3</version>
        <configuration>
          <!-- this is false by default -->
          <generateClient>true</generateClient>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>

然后,它将生成一个客户端,您将能够将其用作依赖项:

<project>
  [...]
  <dependencies>
    <dependency>
      <groupId>com.example</groupId>
      <artifactId>ejb-project</artifactId>
      <version>1.0-SNAPSHOT</version>
      <type>ejb-client</type>
    </dependency>
  </dependencies>
  [...]
</project>

或更好

<project>
  [...]
  <dependencies>
    <dependency>
      <groupId>com.example</groupId>
      <artifactId>ejb-project</artifactId>
      <version>1.0-SNAPSHOT</version>
      <type>ejb</type>
              <classifier>client</classifier>
    </dependency>
  </dependencies>
  [...]
</project>

我没有任何真实的例子(我在我的个人电脑上,而不是我的工作电脑),但我记得我们使用了第二种方法的依赖。

答案 1 :(得分:1)

如果你有单独的maven项目,这是分离接口(api)和实现的常用方法。当然,您可以单独部署接口和实现。