[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);
相关文章
|
10天前
|
存储 IDE Java
漂亮不是梦!Java Swing美化攻略
Java Swing 是一个为 Java 设计的 GUI 工具包,提供文本框、按钮等组件。尽管其外观可定制,通过 Look and Feel(LAF)机制改变应用风格,如 Darcula 和 FlatLaf,但现已淡出主流视野,主要应用于 IDE 领域,如 IntelliJ IDEA 和 Eclipse。相比其他 GUI 框架,Swing 的发展前景有限。
28 1
|
2月前
|
JSON Java 关系型数据库
Java更新数据库报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
在Java中,使用mybatis-plus更新实体类对象到mysql,其中一个字段对应数据库中json数据类型,更新时报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
102 4
Java更新数据库报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
|
2月前
|
Java Linux Windows
Java“Could Not Create Java Virtual Machine”解决
当在Java中遇到“Could Not Create Java Virtual Machine”错误时,通常是由于内存设置不当、Java版本不兼容、类路径错误或操作系统限制等原因导致JVM无法启动。解决方法包括调整内存参数、确认Java版本兼容性、检查类路径和启动参数、以及检查用户权限和文件系统。
353 1
|
7月前
|
前端开发 Java 图形学
[笔记] 疯狂JAVA讲义(第3版)第11章 AWT编程
[笔记] 疯狂JAVA讲义(第3版)第11章 AWT编程
|
4月前
|
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
230 2
|
4月前
|
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
58 2
|
5月前
|
安全 Java API
|
5月前
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
81 3
|
5月前
|
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
48 2
|
5月前
Unable to create tempDir. java.io.tmpdir is set to /tmp
Unable to create tempDir. java.io.tmpdir is set to /tmp
61 0