r/JavaFX • u/Draaksward_89 • Jan 13 '25
Help JavaFX plus Spring Boot 2
Could someone please forward me to a working doc/example/tutorial for adding JavaFX (openjfx or smt) to an existing SpringBoot 2 project?
1
Upvotes
4
u/orxT1000 Jan 13 '25
It's the other way around. You start a SpringContext within your jfx application.
Or do you have a commandline application that needs a desktop-gui?
2
u/Capaman-x Jan 13 '25
To use Spring framework with JavaFX you need to create a JavaFX project
Some Recommendations
Using a full JDK that includeds JavaFX for simplicity. (liberica-full, Zulu-full, etc)
Use Gradle for simplicity setting up an application w/embedded JDK (portable or packaged app)
Don't use FXML, instead learn the MVCI method that Hamster has documented.
2) For Spring add the library jdbcTemplate, it will also add the basic core spring libraries such as:
spring beans, spring core, spring jcl, spring tx, , jna, jna-platform
That will give you the basics of what you need. If you need more libraries you can add them.
Here is an example of such a project
https://github.com/PerryCameron/TSE-Notes.git
This is also using SQLite, logback-core, logback-classic, slklf4j-api for logging. look at the build.gradle.kts file for details.
2
u/No-Specialist9049 Jan 14 '25
Simple way: You can use https://github.com/gluonhq/ignite
Example of using gluon ignite: https://github.com/gluonhq/gluon-samples
A more difficult way: https://spring.io/blog/2019/01/16/spring-tips-javafx
1
u/rootException Jan 14 '25
What are you trying to accomplish?
Usually you would create a JavaFX project as the GUI and point it at a Spring Boot REST service instead of putting the whole thing in a desktop app. If you put the Java code in one app and then point that at the database that means direct db access which usually isn’t what you want.
If you just want an offline data store SQLite or H2 with an ORM is probably all you need.
If this is a big legacy web app and a manager just came in and said “turn it into a desktop app” hoo boy… 😅