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

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

[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);
相关文章
|
5月前
|
前端开发 Java 图形学
[笔记] 疯狂JAVA讲义(第3版)第11章 AWT编程
[笔记] 疯狂JAVA讲义(第3版)第11章 AWT编程
|
2月前
|
Java API Nacos
Caused by: java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forge
Caused by: java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forge
|
2月前
|
Java
flyway报错Caused by: java.lang.NoSuchMethodError: org.flywaydb.core.api.configuration.FluentConfigurat
flyway报错Caused by: java.lang.NoSuchMethodError: org.flywaydb.core.api.configuration.FluentConfigurat
30 2
|
3月前
|
安全 Java API
|
3月前
|
Android开发
Cannot create android app from an archive...containing both DEX and Java-bytecode content
Cannot create android app from an archive...containing both DEX and Java-bytecode content
30 2
|
3月前
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
48 3
|
3月前
Unable to create tempDir. java.io.tmpdir is set to /tmp
Unable to create tempDir. java.io.tmpdir is set to /tmp
37 0
|
3月前
|
SQL Java 数据库连接
【Java】Java Swing 图书管借阅管理系统(源码+论文)【独一无二】
【Java】Java Swing 图书管借阅管理系统(源码+论文)【独一无二】
115 0
|
3月前
|
存储 数据可视化 Java
【Java】Java swing 民宿管理系统 GUI(源码+可视化界面)【独一无二】
【Java】Java swing 民宿管理系统 GUI(源码+可视化界面)【独一无二】
|
5月前
|
Java 数据安全/隐私保护
利用Java图形化界面组件Swing写一个简易的登录界面
利用Java图形化界面组件Swing写一个简易的登录界面
58 1