在使用mvn命令启动Springboot项目时候,想使用命令参数的方式指定启动时候使用哪个配置文件,在
使用-Drun.jvmArguments="-Dspring.profiles.active=test"时总是提示错误:
mvn spring-boot:run -Drun.jvmArguments="-Dspring.profiles.active=test" -X
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< com.chqiuu.online:online-test >--------------------
[INFO] Building online-test 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.406 s
[INFO] Finished at: 2022-02-24T14:07:16+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase ".profiles=test". 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
经过多次测试,使用以下方式命令即可解决
mvn spring-boot:run -D"spring-boot.run.profiles"=test