gpt4 book ai didi

jakarta-ee - maven-ear-plugin 不包含 jarModule 到 application.xml

转载 作者:行者123 更新时间:2023-12-03 12:38:04 24 4
gpt4 key购买 nike

我一直在关注 maven-ear-plugin 站点上的示例 shows how to add third-party libraries to the generated application.xml .但是,它似乎没有像我预期的那样工作。同样的网络模块contextRoot被忽略。

根据documentation我想做的事情应该是完全可能的。

The context root of a Web module might be customized using the contextRoot parameter.

Please note that third party libraries (i.e. JarModule) are not included in the generated application.xml (only ejb-client should be included in a java entry). However, a jar dependency could be included in the generated application.xml by specifying the includeInApplicationXml flag.



当它在我的 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 标签,但它不会让我因为我不够有名!如果有人可以创造,我将不胜感激。

    最佳答案

    我像往常一样解决了它,这是用户错误。

    奇怪的是,它几乎正确地生成了 EAR 文件,即使我的插件没有正确配置。

    我换了...

    <groupId>maven-ear-plugin</groupId>
    <artifactId>maven-ear-plugin</artifactId>

    和...
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>

    然后变了...
    <includeLibInApplicationXml>true</includeLibInApplicationXml>

    到...
    <includeInApplicationXml>true</includeInApplicationXml>

    然后突然间它做了我一开始打算做的事情。

    我的最终 pom.xml 看起来像这样,因为我决定要自动包含所有 jar。
    <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.blah</groupId>
    <artifactId>MyApp.EAR</artifactId>
    <version>1.0</version>
    <packaging>ear</packaging>

    <properties>
    <weblogic.version>10.3</weblogic.version>
    <weblogic.version.minor>${weblogic.version}.4</weblogic.version.minor>
    <weblogic.host>***</weblogic.host>
    <weblogic.port>***</weblogic.port>
    <weblogic.username>***</weblogic.username>
    <weblogic.password>***</weblogic.password>
    </properties>

    <build>
    <finalName>MyApp</finalName>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <version>2.7</version>
    <configuration>
    <applicationName>MyApp</applicationName>
    <includeLibInApplicationXml>true</includeLibInApplicationXml>
    <modules>
    <ejbModule>
    <groupId>com.blah</groupId>
    <artifactId>MyApp.EJB</artifactId>
    </ejbModule>
    <webModule>
    <groupId>com.blah</groupId>
    <artifactId>MyApp.Web</artifactId>
    <contextRoot>MyApp</contextRoot>
    </webModule>
    </modules>
    <archive>
    <manifestEntries>
    <WebLogic-Application-Version>${weblogic.version}</WebLogic-Application-Version>
    </manifestEntries>
    </archive>
    </configuration>
    </plugin>

    <plugin>
    <groupId>com.oracle.weblogic</groupId>
    <artifactId>weblogic-maven-plugin</artifactId>
    <version>10.3.4</version>
    <configuration>
    <adminurl>t3://${weblogic.host}:${weblogic.port}</adminurl>
    <user>${weblogic.username}</user>
    <password>${weblogic.password}</password>
    <upload>true</upload>
    <action>deploy</action>
    <remote>false</remote>
    <verbose>true</verbose>
    <source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
    <name>${project.build.finalName}</name>
    </configuration>
    <executions>
    <execution>
    <phase>install</phase>
    <goals>
    <goal>deploy</goal>
    </goals>
    </execution>
    </executions>
    </plugin>

    </plugins>

    <pluginManagement>
    <plugins>
    <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
    <plugin>
    <groupId>org.eclipse.m2e</groupId>
    <artifactId>lifecycle-mapping</artifactId>
    <version>1.0.0</version>
    <configuration>
    <lifecycleMappingMetadata>
    <pluginExecutions>
    <pluginExecution>
    <pluginExecutionFilter>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <versionRange>[2.7,)</versionRange>
    <goals>
    <goal>generate-application-xml</goal>
    </goals>
    </pluginExecutionFilter>
    <action>
    <ignore></ignore>
    </action>
    </pluginExecution>
    </pluginExecutions>
    </lifecycleMappingMetadata>
    </configuration>
    </plugin>
    </plugins>
    </pluginManagement>
    </build>

    <dependencies>
    <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>
    </project>

    关于jakarta-ee - maven-ear-plugin 不包含 jarModule 到 application.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12093346/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com