When I was looking for information about when to create a Maven + Spring + JavaFX project, I constantly encountered the following problems:
- Constantly getting into the search results are some libraries that offer their own architecture and configuration of a project like Spring Boot. I’m also interested in JavaFX and Spring as separate libraries that do not involve large-scale changes in the configuration and structure of an existing project.
- I did not find a single example with a single way to determine maven dependencies. Here for example an article on Habré about the integration of Maven, Spring, JavaFX. Fine. Only where in pom.xml is JavaFX listed among dependencies? In this example, we add JavaFX to the plugins field. This is also a failure: somehow annoying when spring is in dependencies, and javafx is in plugins.
- There are plenty of JavaFX libraries in Maven repositories , and which one to use is not clear. Naturally, we are primarily interested in maven-dependence on the official developer, that is, Oracle, and libraries from third parties are undesirable.
Generally speaking, to answer this question, it is enough to add the dependency dependencies to the official developer of this technology in the POM.xml below, which defines the basic JavaFX functionality.
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>JavaFX_Spring_Maven</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <!-- https://mvnrepository.com/artifact/org.springframework/spring-context --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.0.8.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>5.0.8.RELEASE</version> </dependency> </dependencies> </project>
Main.java,main.fxmlandMainController.javaand of course the code. Libraries extend core JavaFX functionality - Tsyklop