【问题标题】:mvn spring-boot:run from command lime but choose which class to runmvn spring-boot:从命令行运行,但选择要运行的类
【发布时间】:2018-10-12 22:23:54
【问题描述】:

我需要从命令lime 运行mvn spring-boot:run,但选择要运行的主类。有办法吗?我需要在命令行中运行它,而不是从 JAR 中运行。

【问题讨论】:

    标签: maven spring-boot spring-boot-maven-plugin


    【解决方案1】:

    mvn spring-boot:run -Dstart-class=your.main.class 应该可以工作

    来自mvn help:describe -Dcmd=spring-boot:run -Ddetail的可用选项的完整列表

    编辑:对于 2.0.1.RELEASE,“user”参数更改为spring-boot.run.main-class,但命令应该相同。

    https://docs.spring.io/spring-boot/docs/2.0.1.RELEASE/maven-plugin/run-mojo.html

    【讨论】:

    • 您使用的是什么版本的插件?我已经为 2.0.1.RELEASE 编辑了答案
    • 我再次编辑了我的答案,并确认了 maven 3.5.0 和 spring-boot 插件 1.5.10.RELEASE 和 2.0.1.RELEASE 的行为。官方文档(在答案中链接)实际上对我来说很难理解,所以我进行了实验。希望改进后的答案有所帮助。
    猜你喜欢
    • 2016-11-16
    • 1970-01-01
    • 2017-04-06
    • 2021-01-16
    • 1970-01-01
    • 1970-01-01
    • 2020-10-29
    • 2021-11-26
    • 1970-01-01
    相关资源
    最近更新 更多