多模块项目的Maven配置

时间:2017-04-24 18:05:30

标签: spring maven spring-mvc spring-boot multi-module

我正在使用Spring Boot创建一个多模块项目,该项目将有3个模块:moduleA,moduleB和moduleC。

我正在关注本教程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 个答案:

答案 0 :(得分:1)

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

  

[错误]您指定的目标需要执行项目,但此目录中没有POM(/Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/multi-module-project-example )。

在本教程中查看多模块项目的Maven配置库的Maven配置。在那里,您将找到必要的pom.xml文件。

答案 1 :(得分:0)

有两件事:

  1. 要运行任何maven项目,最基本的第一个要求是必须有pom.xml。缺少此文件会引发错误:

      

    [错误]您指定的目标需要项目执行但在那里   这个目录中没有POM   (/Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/multi-module-project-example)。   请验证您是否从正确的目录中调用了Maven。 - &GT; [救命   1]

  2. 在教程https://spring.io/guides/gs/multi-module/#scratch中提到您应该拥有pom.xml文件,请参阅此部分 ▶多模块项目的Maven配置