[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);
相关文章
|
24天前
|
Java Linux Windows
Java“Could Not Create Java Virtual Machine”解决
当在Java中遇到“Could Not Create Java Virtual Machine”错误时,通常是由于内存设置不当、Java版本不兼容、类路径错误或操作系统限制等原因导致JVM无法启动。解决方法包括调整内存参数、确认Java版本兼容性、检查类路径和启动参数、以及检查用户权限和文件系统。
|
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
140 2
|
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
40 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
37 2
|
3月前
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
66 3
|
3月前
Unable to create tempDir. java.io.tmpdir is set to /tmp
Unable to create tempDir. java.io.tmpdir is set to /tmp
47 0
|
3月前
|
SQL Java 数据库连接
【Java】Java Swing 图书管借阅管理系统(源码+论文)【独一无二】
【Java】Java Swing 图书管借阅管理系统(源码+论文)【独一无二】
158 0
|
3月前
|
存储 数据可视化 Java
【Java】Java swing 民宿管理系统 GUI(源码+可视化界面)【独一无二】
【Java】Java swing 民宿管理系统 GUI(源码+可视化界面)【独一无二】
下一篇
无影云桌面