我從pom.xml 中的檔案中復制粘貼了以下片段
<plugin>
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/resources</outputDirectory>
<resources>
<resource>
<directory>${basedir}/template</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
但是當我嘗試觸發部署時收到以下訊息:
$ mvn resources:copy-resources
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< org.test:myproject >------------------------
[INFO] Building myproject-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:copy-resources (default-cli) @ myproject ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.440 s
[INFO] Finished at: 2021-12-26T12:30:59 01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:copy-resources (default-cli) on project myproject: The parameters 'resources', 'outputDirectory' for goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:copy-resources are missing or invalid -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException
這是我的目錄結構:
./resources
./template
./template/test.txt
./pom.xml
如何更改資源的目標檔案夾?為什么 maven 沒有決議插件中的配置指令?
uj5u.com熱心網友回復:
執行特定 maven 目標的完整命令語法是:
mvn <plugin>:<goal>@<executionId>
當沒有指定 executionId 時,它default-cli默認等于。
現在您執行mvn resources:copy-resources這等效于mvn resources:copy-resources@default-cli但您pom.xml沒有為此目標定義此執行 ID。所以它抱怨一些引數丟失并且沒有配置好。
當您將執行 id 定義為 時copy-resources,這意味著您應該執行:
mvn resources:copy-resources@copy-resources
或者,當您將此目標系結到validate階段時,這意味著您也可以通過以下方式簡單地執行它:
mvn validate
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/394230.html
