我有一个简单的maven项目,然而令人沮丧的是几个小时都没能完成它。该项目包含1个父模块和2个子模块(一个用于耳包装,另一个用于ejb)。建筑工作成功,但耳包装不能按预期工作:
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>at.betrieb.projekt</groupId>
<artifactId>extended</artifactId>
<version>1.0</version>
</parent>
<artifactId>extended-ear</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>at.betrieb.projekt</groupId>
<artifactId>extended-ejb</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<version>6</version>
<generateApplicationXml>false</generateApplicationXml>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<jarModule>
<groupId>at.betrieb.projekt</groupId>
<artifactId>extended-ejb</artifactId>
<bundleDir>/</bundleDir>
</jarModule>
</configuration>
</plugin>
</plugins>
</build>
</project>
现在,当我查看打包文件夹时,我看到了这个结构:
|-lib
extended-ejb-1.0.jar
activation-1.1.jar
javaee-api-7.0.jar
javax.mail-1.5.0.jar
|-META-INF
application.xml
我的预期是这个结构:
|-extended-ejb-1.0.jar
|-lib
activation-1.1.jar
javaee-api-7.0.jar
javax.mail-1.5.0.jar
|-META-INF
application.xml
所以基本上我想把ejb放在其他库之外。这些其他3个库来自ejb-module,它需要javaee-api
依赖注释。不幸的是,它还收集传递javax.mail.jar,activation.jar。
现在我真的不知道为什么结构不能按预期工作,我试图遵循this guide step by step。
答案 0 :(得分:1)
好的,在我从各种maven原型中检出一个项目之后,我发现了错误......最小的错误......它总是一个耗费大量时间的最小错误......
在ear文件的dependencies部分中,我将ejb定义为依赖项,只需添加:
<type>ejb</type>
所以它是:
<dependency>
<groupId>at.betrieb.projekt</groupId>
<artifactId>extended-ejb</artifactId>
<version>1.0</version>
<type>ejb</type>
</dependency>
之后它正常工作。显然,在IBM页面和许多其他页面上都是错误的。除了我发现以下部分也已过时,可以从ear-plugin部分完全删除:
<jarModule>
<groupId>at.betrieb.projekt</groupId>
<artifactId>extended-ejb</artifactId>
<bundleDir>/</bundleDir>
</jarModule>