我正在使用 Maven 3.2.1 和 Eclipse Kepler 。我有一个动态Web项目,它依赖于包含一些JSP的另一个组件。我现在希望依赖项中的JSP成为动态Web项目的Web根目录的一部分。我选择使用 maven-dependency-plugin 的 unpack 目标来实现这一目标。
我添加了一个插件定义,将JAR解压缩到/target/m2e-wtp/web-resources
。 Unfortunatley Eclipse不时清理这个文件夹,而且JSP已经不见了。为了再次解压缩,我必须删除target/dependency-maven-plugin-markers
文件夹。否则插件将不会再次解压缩文件。
是否可以强制解压缩并忽略插件标记?
有没有更好的方法将Web资源从依赖项导入我的Dynamic Web Project?
答案 0 :(得分:1)
是的,有更好的方法,但它与Tomcat的“没有发布的服务模块”功能(或Weblogic的等效功能)不兼容
删除maven-dependency-plugin配置,并将您的依赖项添加为war覆盖。如果您的依赖项是战争,它将自动识别为叠加层(http://maven.apache.org/plugins/maven-war-plugin/overlays.html)。如果是zip或jar,则需要在maven-war-plugin定义中添加特定配置。一些事情:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<overlays>
<overlay>
<!-- /!\ must also be added as a project dependency-->
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<type>jar</type>
<targetPath>relative/path/to/contextroot</targetPath>
</overlay>
</overlays>
</configuration>
</plugin>
在部署之前,资源将在target / m2e-wtp / overlays / bar-version.jar /下解压缩,然后部署到您的应用程序服务器上