Maven,Ear包将依赖关系放在Ear和Web模块下

Fabrizio Stellato:

我有一个耳模,如此组成:

耳朵ejb网站

我正在使用maven来管理软件包;每个模块都有自己的pom.xml

现在,让我们说出ear模块pom.xml是这样的:

<dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>myproject-ejb</artifactId>
            <type>ejb</type>
        </dependency>

        <!-- Depend on the EJB module and WAR so that we can package them -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>myproject-web</artifactId>
            <type>war</type>
        </dependency>

<build>
    <finalName>${project.parent.artifactId}</finalName>
    <plugins>
        <!--EAR plugin: format of output file -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>${version.ear.plugin}</version>
            <configuration>
                <!-- Tell Maven we are using Jakarta EE -->
                <version>8</version>
                <!-- Use Jakarta EE ear libraries as needed. Jakarta EE ear libraries
                    are in easy way to package any libraries needed in the ear, and automatically
                    have any modules (EJB-JARs and WARs) use them -->
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <modules>
                <!-- Default context root of the web app is /customers-web.
                    If a custom context root is needed, uncomment the following snippet to
                    register our War as a web module and set the contextRoot property -->
                <!--
                <webModule>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>customers-web</artifactId>
                    <contextRoot>/customers</contextRoot>
                </webModule>
                -->
                </modules>
                <outputFileNameMapping>@{artifactId}@@{dashClassifier?}@.@{extension}@</outputFileNameMapping>
            </configuration>
        </plugin>
        <!-- The WildFly plug-in deploys your ear to a local JBoss EAP container. 
            Due to Maven's lack of intelligence with EARs we need to configure
            the WildFly Maven plug-in to skip deployment for all modules. We then enable
            it specifically in the ear module. -->
        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <configuration>
                <skip>false</skip>
            </configuration>
        </plugin>
    </plugins>
</build>

..这是根上的pom.xml

    <dependency>
        <groupId>org.burp</groupId>
        <artifactId>some-lib</artifactId>
        <scope>compile</scope>
    </dependency>

当我编译ear时,我可以看到some-lib.jar位于{root} / lib和myproject-web / WEB-INF / lib上。

如何将所有依赖项仅放在{root} / lib上

JF Meier:

您可以在war模块中覆盖依赖项的范围,例如:

<dependency>
    <groupId>org.burp</groupId>
    <artifactId>some-lib</artifactId>
    <scope>provided</scope>
</dependency>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章