我们在做SpringBoot项目开发的时候,特别是微服务集群开发,本地是需要启动多个服务的,这个时候就有多种方式可以选择了,可以在终端上启动,也可以在IDEA等IDE中启动,这里说说使用的方式,在使用前先说个坑,在Win开发环境时,使用了Win的Powershell窗口使用mvn spring-boot:run -Dspring.profiles.active=peer的方式启动一个节点服务,始终报错,
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building eureka-server 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.270 s
[INFO] Finished at: 2019-02-18T23:52:16+08:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase ".profiles.active=peer". 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/LifecyclePhaseNotFoundException
而且这里怎么就扯到maven的lifecycle?研究了很久,简直莫名其妙,然后好奇试了下直接使用cmd窗口启动,启动成功了,最后得出的结论就是没事不要使用Powershell,简直浪费时间。下面我们来说说Spring Boot启动的方式。