【发布时间】:2011-06-13 05:57:06
【问题描述】:
当我使用 maven 创建一个 war 包时,目录“src/main/resources”下的文件和目录被复制到 /WEB-INF/classes 而不是 /WEB-INF。如何将它们复制到 /WEB-INF?
谢谢, 兰德
更新: 现在我在我的 pom 中使用这个:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>war</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>myapp/target/WEB-INF</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
然后我启动 mvn:
mvn -Dmaven.test.skip=true clean package resources:copy-resources
但我得到了:
[INFO] One or more required plugin parameters are invalid/missing for 'resources:copy-resources'
[0] Inside the definition for plugin 'maven-resources-plugin' specify the following:
<configuration>
...
<outputDirectory>VALUE</outputDirectory>
</configuration>.
[1] Inside the definition for plugin 'maven-resources-plugin' specify the following:
<configuration>
...
<resources>VALUE</resources>
</configuration>.
我使用的是 maven 2.2,sn-p 基本上与文档相同 有什么想法吗?
【问题讨论】:
-
不要运行
resources:copy-resources目标,它会自动包含在阶段copy-resources中(在我的答案中)