gpt4 book ai didi

Maven:如何获取在WEB-INF中复制资源的war包?

转载 作者:行者123 更新时间:2023-12-03 11:06:15 24 4
gpt4 key购买 nike

当我使用 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 并且代码段基本上与文档相同
任何的想法?

最佳答案

要么配置 outputDirectory resources:resources 的参数插件,或将您的文件放在 src/main/webapp/WEB-INF/ 下目录。
resource plugin

编辑:

此配置对我有用:

  <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.2</version>
<executions>
<execution>
<id>default-copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>

您可以以 somePhase 的形式运行阶段或目标 somePlugin:someGoal .阶段调用将依次调用在区间 [validate,phase] 中与阶段 Hook 的所有插件目标,因此无需显式调用它们。

关于Maven:如何获取在WEB-INF中复制资源的war包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4760827/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com