无头运行 Spring Boot [英] Run Spring Boot Headless

查看:73
本文介绍了无头运行 Spring Boot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Spring Boot 应用程序,我想无头运行它.当我从终端运行时,这是我正在使用的命令:

I have a spring boot application and I would like to run it headless. When I run from the terminal this is the command I'm using:

java -jar myapp.jar --spring.main.headless=true

java -jar myapp.jar --spring.main.headless=true

这是正确的吗?任何帮助都非常感谢.

Is this correct? Any help is well appreciated.

推荐答案

我遇到了同样的问题,并使用 SpringApplicationBuilder 类解决了它.您应该将 headless 设置为 false(默认情况下为 true).请参阅 javadoc.

I've faced with same problem and solved it using SpringApplicationBuilder class. You should set headless false (which is true by default). See javadoc.

我的主要方法如下所示:

My main method looks like this:

  public static void main(String[] args) {
    SpringApplicationBuilder builder = new SpringApplicationBuilder(App.class);
    builder.headless(false).run(args);
  }

这篇关于无头运行 Spring Boot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆