2017-04-24 164 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配置多模块项目