如何正确使用SNAPSHOTS与EAR和EJB的依赖关系 [英] How do I correctly use SNAPSHOTS dependencies with EARs and EJBs
问题描述
我正在尝试在EAR中构建EJB。我的EJB依赖于SNAPSHOTS。因此,当我构建EAR时,我的结构如下所示:
I am trying to build an EJB in an EAR. My EJB has dependencies on SNAPSHOTS. So when I build the EAR my structure looks like this:
my-ear-1.0.0-SNAPSHOT.ear
+ META-INF
- application.xml
- MANIFEST.MF
- my-ejb-1.0.0-SNAPSHOT.jar
- third-party-lib-1.0.0-SNAPSHOT.jar
然而,当使用maven-ejb-plugin生成其MANIFEST.MF时:
However, when using the maven-ejb-plugin to generate its MANIFEST.MF:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
我遇到的问题是MANIFEST.MF列出了SNAPSHOT在Nexus中的显示方式而不是maven-ear-plugin在构建耳朵时如何命名它。
The problem I have, is the MANIFEST.MF lists the SNAPSHOT as how it appears in Nexus which is not how the maven-ear-plugin named it when building the ear.
Manifest-Version: 1.0
Build-Jdk: 1.6.0_25
Class-Path: third-party-lib-1.0.0-20121026.140152-21.jar
所以我当然得到 ClassNotFoundException ,因为EJB类路径正在寻找一个不存在的jar文件。
So of course I'm getting ClassNotFoundException s because the EJBs classpath is looking for a jar file that doesn't exist.
基本上我需要知道:
- 我如何获得maven -ear-plugin在没有-SNAPSHOT格式的情况下将罐子插入耳中?
- 如何让maven-ejb-plugin在MANIFEST.MF中使用-SNAPSHOT格式?
推荐答案
通过查看maven archiver文档,我找到了解决问题的方法。 a href =http://maven.apache.org/shared/maven-archiver/examples/classpath.html#aSnapshot\"rel =noreferrer> Maven Archiver - 处理快照。
I found the solution to my problem by looking through the maven archiver documentation at Maven Archiver - Handling Snapshots.
我只是需要配置我的maven-ejb-plugin,以便它不使用唯一版本:
I just needed to configure my maven-ejb-plugin so that it didn't use "unique versions":
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</archive>
</configuration>
</plugin>
下次RTFM更接近我猜:)
RTFM closer next time I guess :)
这篇关于如何正确使用SNAPSHOTS与EAR和EJB的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!