我有3个项目。第一个读取数据库并为我的ejb创建所有的类文件。第二个是我的ejbs。第三个是我的.ear项目,应该将第二个项目中的ejb .jar打包到.ear中。
项目1可以正常运行,并且可以作为Java应用程序运行。
Project 2可以正常运行,并且具有几种maven运行配置,一种可以创建客户端jar,一种可以将这些客户端jar部署到Nexus,一种可以创建ejb .jar,并将其打包在已部署的.ear中。到服务器。
项目3是一个问题。过去,我只是将.ear导出到eclipse中,并且效果很好。现在,我试图使其与Maven一起使用。我基本上可以使用它,但是它一直包含一堆库文件,并且正在复制错误的文件。
这是pom
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.kable.newsstand.kdsejb</groupId>
<artifactId>kds-ejb-ear</artifactId>
<version>1.0.0</version>
<packaging>ear</packaging>
<parent>
<groupId>com.kable.maven</groupId>
<artifactId>kable-super-pom</artifactId>
<version>[0.1,1.0)</version>
</parent>
<dependencies>
<dependency>
<groupId>com.kable.newsstand.kdsejb</groupId>
<artifactId>kds-ejb</artifactId>
<version>1.1.0-SNAPSHOT</version>
<type>ejb</type>
</dependency>
</dependencies>
<build>
<finalName>kdsejbEar</finalName>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.10</version>
<configuration>
<earSourceDirectory>EarContent</earSourceDirectory>
<modules>
<ejbModule>
<groupId>com.kable.newsstand.kdsejb</groupId>
<artifactId>kds-ejb</artifactId>
<bundleFileName>kdsSession.jar</bundleFileName>
</ejbModule>
</modules>
<displayName>kdsejbEar</displayName>
<generateApplicationXml>true</generateApplicationXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
第二个项目具有运行配置,该配置创建ejb .jar并将其命名为kdsSession.jar
<plugin>
<artifactId>maven-ejb-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<jarName>kdsSession</jarName>
<outputDirectory>${basedir}</outputDirectory>
<ejbVersion>3.1</ejbVersion>
<archive>
<manifestEntries>
<Dependencies>org.apache.commons.lang3</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
我想在我的.ear中使用那个jar。以下是ear项目的输出。
[INFO] Scanning for projects...
[WARNING] Failed to build parent project for com.kable.newsstand.kdsejb:kds-ejb-ear:ear:1.0.0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building kds-ejb-ear 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ kds-ejb-ear ---
[INFO] Deleting C:\Users\bray\eclipse-workspaces\kds-ejb\kdsejbEar\target
[INFO]
[INFO] --- maven-ear-plugin:2.10:generate-application-xml (default-generate-application-xml) @ kds-ejb-ear ---
[WARNING] The POM for org.apache.commons:commons-compress:jar:1.9 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] Generating application.xml
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ kds-ejb-ear ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\bray\eclipse-workspaces\kds-ejb\kdsejbEar\src\main\resources
[INFO]
[INFO] --- maven-ear-plugin:2.10:ear (default-ear) @ kds-ejb-ear ---
[INFO] Copying artifact [ejb:com.kable.newsstand.kdsejb:kds-ejb:1.1.0-20181024.164321-158] to [kdsSession.jar]
[INFO] Copying artifact [jar:org.jboss.spec.javax.ejb:jboss-ejb-api_3.1_spec:1.0.2.Final] to [jboss-ejb-api_3.1_spec-1.0.2.Final.jar]
[INFO] Copying artifact [jar:org.jboss.ejb3:jboss-ejb3-ext-api:2.2.0.Final] to [jboss-ejb3-ext-api-2.2.0.Final.jar]
[INFO] Copying artifact [jar:org.hibernate:hibernate-envers:5.1.13.Final] to [hibernate-envers-5.1.13.Final.jar]
[INFO] Copying artifact [jar:org.jboss.logging:jboss-logging:3.3.0.Final] to [jboss-logging-3.3.0.Final.jar]
[INFO] Copying artifact [jar:org.hibernate:hibernate-core:5.1.13.Final] to [hibernate-core-5.1.13.Final.jar]
[INFO] Copying artifact [jar:org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final] to [hibernate-jpa-2.1-api-1.0.0.Final.jar]
[INFO] Copying artifact [jar:org.javassist:javassist:3.20.0-GA] to [javassist-3.20.0-GA.jar]
[INFO] Copying artifact [jar:antlr:antlr:2.7.7] to [antlr-2.7.7.jar]
[INFO] Copying artifact [jar:org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1.1] to [geronimo-jta_1.1_spec-1.1.1.jar]
[INFO] Copying artifact [jar:org.jboss:jandex:2.0.3.Final] to [jandex-2.0.3.Final.jar]
[INFO] Copying artifact [jar:dom4j:dom4j:1.6.1] to [dom4j-1.6.1.jar]
[INFO] Copying artifact [jar:org.hibernate:hibernate-commons-annotations:3.2.0.Final] to [hibernate-commons-annotations-3.2.0.Final.jar]
[INFO] Copying artifact [jar:org.slf4j:slf4j-api:1.5.8] to [slf4j-api-1.5.8.jar]
[INFO] Copying artifact [jar:org.hibernate:hibernate-entitymanager:5.1.13.Final] to [hibernate-entitymanager-5.1.13.Final.jar]
[INFO] Copying artifact [jar:org.apache.commons:commons-lang3:3.5] to [commons-lang3-3.5.jar]
[INFO] Copy ear sources to C:\Users\bray\eclipse-workspaces\kds-ejb\kdsejbEar\target\kdsejbEar
[INFO] Could not find manifest file: C:\Users\bray\eclipse-workspaces\kds-ejb\kdsejbEar\target\kdsejbEar\META-INF\MANIFEST.MF - Generating one
[INFO] Building jar: C:\Users\bray\eclipse-workspaces\kds-ejb\kdsejbEar\target\kdsejbEar.ear
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:47 min
[INFO] Finished at: 2018-10-25T14:09:10-05:00
[INFO] Final Memory: 17M/332M
[INFO] ------------------------------------------------------------------------
如您所见,由于某种原因,它正在复制某些库文件。我不要那些。它还没有得到预先存在的kdsSession.jar,而是创建了一个新的kdsSession.jar。
如何纠正此行为?
答案 0 :(得分:1)
在您的耳朵项目中运行mvn dependency:tree
看看它,然后找出不想要的罐子从哪里来。
也许您在kds-ejb
项目中声明了依赖项。
在这种情况下,请将范围设置为提供。
有关范围的更多信息,请访问Introduction to the Dependency Mechanism