技术雷达

[SOLVED] Caused by: java.awt.Hea

2018-09-30  本文已影响20人  光剑书架上的书

[SOLVED] Caused by: java.awt.HeadlessException when trying to create a SWING/AWT frame from Spring Boot

In Spring Boot, when you try to create a Swing frame from the component that is the entry point of your app, you will get

Caused by: java.awt.HeadlessException

To solve this, in your Application class in main, instead of:

SpringApplication.run (Application.class, args)

use

SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class);
builder.headless(false);
ConfigurableApplicationContext context = builder.run(args);
上一篇 下一篇

猜你喜欢

热点阅读