【发布时间】:2012-07-01 14:09:36
【问题描述】:
我有一个带有无状态会话 bean 的 ejb。我有每个 bean 的接口,可以从另一台机器的另一个 ejb 访问或远程调用。在 invy 中,我记得我们使用了类似的东西:publish-remote、publish-api。 maven也能做同样的事情吗?
在单独的 jar 中发布接口,以包含在另一个项目中。
谢谢,
嫖娼
【问题讨论】:
我有一个带有无状态会话 bean 的 ejb。我有每个 bean 的接口,可以从另一台机器的另一个 ejb 访问或远程调用。在 invy 中,我记得我们使用了类似的东西:publish-remote、publish-api。 maven也能做同样的事情吗?
在单独的 jar 中发布接口,以包含在另一个项目中。
谢谢,
嫖娼
【问题讨论】:
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>
我没有任何真实的例子(我在我的个人计算机上,而不是我的工作计算机上),但我记得我们在第二种方法中使用了依赖关系。
【讨论】:
如果您有单独的 Maven 项目,这是分离接口 (api) 和实现的常用方法。当然,您可以单独部署接口和实现。
【讨论】: