Maven在多模块Web项目中:如何将同级模块输出作为JAR放到WEB-INF/类而不是放到WEB-INF/lib中? [英] Maven in multimodule web project: how to put sibling modules output to WEB-INF/classes and not into WEB-INF/lib as JARs?

查看:113
本文介绍了Maven在多模块Web项目中:如何将同级模块输出作为JAR放到WEB-INF/类而不是放到WEB-INF/lib中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多模块Maven项目. 默认情况下,当我构建一个Web模块时,它所依赖的所有JAR类型的同级模块都将复制到WEB-INF/lib文件夹中.我希望将同级模块的输出放置在WEB-INF/classes文件夹中而不打包到JAR.

I have a multi-module Maven project. By default when I build a web module, all sibling modules of type JAR it depends on are copied to WEB-INF/lib folder. I want output of sibling modules to be placed in WEB-INF/classes folder without packaging to JAR.

更普遍的问题可能是:如何将同级模块的配置文件保留在JAR中,以便在部署后可以轻松对其进行编辑?

More general question may be: how to keep sibling modules' configuration files out of JARs so that they can be edited after deployment easily?

推荐答案

如果有人感兴趣,我会找到这种解决方案.我遇到了完全相同的问题.

In case if somebody is interested, I found this solution. I had exactly the same issue.

            <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <configuration>
                        <packagingExcludes>WEB-INF/lib/MYPACKAGE_TO_EXCLUDE.jar</packagingExcludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>unpack-MYPACKAGE_TO_EXCLUDE</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                            <configuration>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>${project.groupId}</groupId>
                                        <artifactId>MYPACKAGE_TO_EXCLUDE</artifactId>
                                        <version>${project.version}</version>
                                        <type>jar</type>
                                        <outputDirectory>${project.build.directory}/classes
                                </outputDirectory>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>

这篇关于Maven在多模块Web项目中:如何将同级模块输出作为JAR放到WEB-INF/类而不是放到WEB-INF/lib中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆