【发布时间】:2012-08-19 01:41:12
【问题描述】:
我一直在关注shows how to add third-party libraries to the generated application.xml 的 maven-ear-plugin 网站上的示例。但是,它似乎没有像我预期的那样工作。同样,Web 模块 contextRoot 被忽略。
根据documentation,我正在尝试做的事情应该是完全可能的。
Web 模块的上下文根可以使用 contextRoot 参数。
请注意,第三方库(即 JarModule)不是 包含在生成的 application.xml 中(只有 ejb-client 应该是 包含在 java 条目中)。但是,可以包含一个 jar 依赖项 在生成的 application.xml 中指定 includeInApplicationXml 标志。
当它在我的 application.xml 中执行构建时,我有以下输出。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC
"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
"http://java.sun.com/dtd/application_1_3.dtd">
<application>
<display-name>MyApp.EAR</display-name>
<module>
<ejb>MyApp.jar</ejb>
</module>
<module>
<web>
<web-uri>MyApp.war</web-uri>
<context-root>/MyApp.Web</context-root>
</web>
</module>
</application>
来自以下 maven 配置 (pom.xml)。
...
<modelVersion>4.0.0</modelVersion>
<groupId>com.blah</groupId>
<artifactId>MyApp.EAR</artifactId>
<version>1.0</version>
<packaging>ear</packaging>
<build>
<plugins>
<plugin>
<groupId>maven-ear-plugin</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<applicationName>MyApp</applicationName>
<modules>
<ejbModule>
<groupId>com.blah</groupId>
<artifactId>MyApp.EJB</artifactId>
</ejbModule>
<webModule>
<groupId>com.blah</groupId>
<artifactId>MyApp.Web</artifactId>
<contextRoot>MyApp</contextRoot>
</webModule>
<jarModule>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<includeLibInApplicationXml>true</includeLibInApplicationXml>
</jarModule>
</modules>
<archive>
<manifestEntries>
<WebLogic-Application-Version>${weblogic.version}</WebLogic-Application-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- web and ejb modules -->
<dependency>
<groupId>com.blah</groupId>
<artifactId>MyApp.EJB</artifactId>
<version>1.0</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.blah</groupId>
<artifactId>MyApp.Web</artifactId>
<version>1.0</version>
<type>war</type>
</dependency>
</dependencies>
...
很明显,application.xml 没有按我的预期生成。
- 在 application.xml 中提供的 contextRoot 不正确,而是输出默认名称 MyApp.Web 而不是指定的 MyApp。
- application.xml 中完全缺少指定的 org.slf4j jarModule。
我做错了什么?
从 Maven 调试如下所示。
[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal: org.apache.maven.plugins:maven-ear-plugin:2.4.2:generate-application-xml (default-generate-application-xml)
[DEBUG] Style: Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<description>${project.description}</description>
<displayName>${project.artifactId}</displayName>
<encoding default-value="UTF-8"/>
<generatedDescriptorLocation>${project.build.directory}</generatedDescriptorLocation>
<includeLibInApplicationXml default-value="false"/>
<project>${project}</project>
<version default-value="1.3"/>
<workDirectory>${project.build.directory}/${project.build.finalName}</workDirectory>
</configuration>
附:我尝试创建 maven-ear-plugin 标签,但它不会让我,因为我不够有名!如果有人能创造出来,我将不胜感激。
【问题讨论】:
-
它似乎完全忽略了我的配置。任何想法为什么??
标签: jakarta-ee maven ear application.xml maven-ear-plugin