简体   繁体   中英

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

在 Spring Boot 中,当您尝试从作为应用程序入口点的组件创建 Swing 框架时,您将获得:

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM