2017-04-24 207 views
0

我正在用Spring Boot創建一個多模塊項目,該項目將有3個模塊:moduleA,moduleB和moduleC。多模塊項目的Maven配置

我下面這個教程https://spring.io/guides/gs/multi-module/#scratch

在根目錄下我創建了3個目錄:moduleA,moduleB和moduleC

我已經運行mvn -N io.takari:maven:wrapper

我已經運行sudo ./mvnw後這裏的結果是:

MacBook-Pro-de-calzada:multi-module-project-example nunito$ sudo ./mvnw 
/Users/nunito/Development/J2EE/workspace-sts-3.8.4.RELEASE/multi-module-project-example 
[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 0.066 s 
[INFO] Finished at: 2017-04-24T20:03:37+02:00 
[INFO] Final Memory: 7M/245M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [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/NoGoalSpecifiedException 
MacBook-Pro-de-calzada:multi-module-project-example nunito$ 

並執行./mvnw clean install

/Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/multi-module-project-example 
[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 0.062 s 
[INFO] Finished at: 2017-04-24T22:38:20+02:00 
[INFO] Final Memory: 8M/309M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/multi-module-project-example). Please verify you invoked Maven from the correct directory. -> [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/MissingProjectException 
MacBook-Pro-de-calzada:multi-module-project-example nunito$ 
+2

什麼是'mvn -N io.takari:maven:wrapper'意味着什麼? –

回答

0

您需要有pom.xml文件才能運行./mvnw clean install

[錯誤]您所指定的目標,需要一個項目來執行,但有這個目錄中沒有POM(/Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/multi-module-項目的例子)。

看一看Maven配置多模塊項目Maven配置在教程庫。在那裏你會找到必要的pom.xml文件。

+0

這是我的想法,但閱讀指南我將運行目標,然後添加pom.xml文件 –

0

有兩件事情:

  1. 爲在運行任何Maven項目中,很基本的,第一個要求是你必須有一個pom.xml。這個文件的缺失會引發你的錯誤:

    [錯誤]您所指定的目標,需要一個項目來執行,但有 沒有POM此目錄中 (/用戶/卡爾薩達/開發/ J2EE/workspace- STS-3.8.4.RELEASE /多模塊項目示例)。 請驗證您是否從正確的目錄中調用了Maven。 - > [求助 1]

  2. 在中提到,你應該有pom.xml文件教程https://spring.io/guides/gs/multi-module/#scratch,請參見本節▶Maven配置多模塊項目