簡體   English   中英

更改 maven 中資源的目標文件夾

[英]changing destination folder of resources in maven

我從我的 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 沒有解析插件中的配置指令?

執行特定 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM