当我用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 =真正的干净包资源: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和片段基本上是相同的文档任何想法?
3 回答
要么配置
resources:resources
插件的outputDirectory
参数,要么将文件放在src/main/webapp/WEB-INF/
目录下 . resource pluginEDIT:
这个配置对我有用:
您可以以
somePhase
或目标somePlugin:someGoal
的形式运行阶段 . 阶段调用将按顺序调用间隔[validate,phase]中阶段上挂钩的所有插件目标,因此不需要显式调用它们 .Web资源与java资源不同,后者应放在类路径中 . Web资源通过war插件处理,应该放在
src\main\webapp\WEB-INF\
中 . 在这种情况下,它将自动工作,而无需在pom.xml中进行任何其他配置这个配置正在工作添加插件pom.xml