Это мой файл pom.xml, который не загружает файл fxml в ресурсы в качестве вывода, а я просто выводю пустую сцену (панель) на экран.Может быть проблема с путём, я вставил код, пожалуйста, дайте мне знать, где я ошибаюсь, пожалуйста, помогите мне решить эту проблему.
Pom.xml
<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.objectiveware</groupId>
<artifactId>QCap</artifactId>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javafx.version>2.2</javafx.version>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<executable>C:\Program Files\Java\jdk1.8.0_191\bin\javac</executable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>attached</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.objectiveware.qcap.QcapAppSingletonRunner</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<configuration>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<JavaFX-Version>${javafx.version}+</JavaFX-Version>
<Main-Class>com.objectiveware.qcap.StartCaptureTaskBar</Main-Class>
<implementation-version>1.0</implementation-version>
<JavaFX-Application-Class>com.objectiveware.qcap.StartCaptureTaskBar</JavaFX-Application-Class>
<Class-Path>javafx-${javafx.version}.jar</Class-Path>
</manifestEntries>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<path id="qcappath">
<pathelement path="${maven.plugin.classpath}"/>
<fileset dir="${project.basedir}">
<include name="package/windows/QCap.ico"/>
</fileset>
</path>
<taskdef name="jfxdeploy" classname="com.sun.javafx.tools.ant.DeployFXTask"
classpathref="qcappath" />
<jfxdeploy width="1024" height="768"
outdir="${project.build.directory}/deploy" outfile="${project.build.finalName}"
nativeBundles="exe" verbose="true">
<info title="${project.name}" />
<application name="${project.name}" mainClass="com.objectiveware.qcap.StartCaptureTaskBar" />
<resources>
<fileset dir="${project.build.directory}" includes="*.jar" />
<fileset dir="${project.build.directory}/dependency"
includes="*.jar" />
</resources>
<platform javafx="${javafx.version}+">
<jvmarg value="-Xms512m" />
<jvmarg value="-Xmx1024m" />
</platform>
</jfxdeploy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ant-javafx</artifactId>
<version>${javafx.version}</version>
<systemPath>${java.home}/../lib/ant-javafx.jar</systemPath>
<scope>system</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>${javafx.version}</version>
<systemPath>${java.home}/lib/ext/jfxrt.jar</systemPath>
<scope>system</scope>
</dependency>
</dependencies>
</plugin> -->
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.docx4j/docx4j -->
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j</artifactId>
<version>6.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.xhtmlrenderer/flying-saucer-pdf-openpdf -->
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf-openpdf</artifactId>
<version>9.1.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.jfoenix/jfoenix -->
<dependency>
<groupId>com.jfoenix</groupId>
<artifactId>jfoenix</artifactId>
<version>1.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform -->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>4.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna -->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.5.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.8.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven/maven-plugin-api -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>${javafx.version}</version>
<systemPath>${java.home}/lib/ext/jfxrt.jar</systemPath>
<scope>system</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.kordamp.bootstrapfx</groupId>
<artifactId>bootstrapfx-core</artifactId>
<version>0.2.4</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
</dependencies>
</project>
Java-класс
пакет com.objectiveware.qcap;
import static com.objectiveware.qcap.controllers.AppController.applicationScreenCapture;
import java.awt.Desktop;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Timer;
import java.util.TimerTask;
import javax.imageio.ImageIO;
import javafx.application.Application;
import javafx.scene.layout.BorderPane;
import org.apache.commons.lang3.StringUtils;
import com.objectiveware.qcap.controllers.LoginController;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class StartCaptureTaskBar
{
private static Timer notificationTimer = new Timer();
private static SystemTray tray;
private static TrayIcon trayIcon;
private Stage stage;
private Stage settingsStage;
private boolean authenticated;
private Runnable exitCallback;
private String userName;
private String password;
private boolean rememberChk;
private boolean StartQCapAtLogin;
public void createInstance(Stage stage, Runnable exitCallback) {
// stores a reference to the stage.
this.stage = stage;
this.exitCallback = exitCallback;
// instructs the javafx system not to exit implicitly when the last application
// window is shut.
Platform.setImplicitExit(false);
// sets up the tray icon (using awt code run on the swing thread).
javax.swing.SwingUtilities.invokeLater(this::addAppToTray);
this.stage.setResizable(false);
this.stage.initStyle(StageStyle.UTILITY);
this.stage.setScene(createLoginContent());
this.stage.setTitle("Login/Setting");
this.stage.show();
}
public void open() {
Platform.runLater(this::showStage);
}
/**
* Callback method invoked to notify that a user has been authenticated. Will
* show the main application screen.
*/
public void authenticated(String sessionID) {
authenticated = true;
startMainPage();
}
public void startMainPage() {
stage.setScene(createMainPageContent());
stage.setTitle("Start Session");
if (applicationScreenCapture != null && applicationScreenCapture.isStoped()) {
applicationScreenCapture.restart();
applicationScreenCapture.startHotKeysKeyboardListner();
stage.hide();
}
}
// TODO: will be implemented later, button will be added in main.fxml for logout
public void logout() {
authenticated = false;
hideSettings();
stage.setScene(createLoginContent("Session expired"));
if (applicationScreenCapture != null) {
applicationScreenCapture.pause();
applicationScreenCapture.pauseHotKeys();
}
showStage();
}
private Scene createLoginContent() {
return createLoginContent("");
}
private Scene createLoginContent(String error) {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/gui/login.fxml"));
Parent root = loader.load();
Scene scene = new Scene(root, 500, 400);
//scene.getStylesheets().add("org/kordamp/bootstrapfx/bootstrapfx.css");
scene.getStylesheets().add(getClass().getResource("/stylesheets/LoginTheme.css").toExternalForm());
LoginController controller = loader.<LoginController>getController();
if (StringUtils.isNotEmpty(error)) {
controller.setErrorMessage(error);
}
controller.initManager(this);
return scene;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
private Scene createMainPageContent() {
try {
Parent root = FXMLLoader.load(getClass().getResource("/gui/main.fxml"));
Scene scene = new Scene(root);
return scene;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* Sets up a system tray icon for the application.
*/
private void addAppToTray() {
try {
java.awt.Toolkit.getDefaultToolkit();
// app requires system tray support, just exit if there is no support.
if (!java.awt.SystemTray.isSupported()) {
System.out.println("No system tray support, application exiting.");
Platform.exit();
}
tray = java.awt.SystemTray.getSystemTray();
java.awt.Image image = ImageIO.read(getClass().getResource("/icons/screenshot.png"));
trayIcon = new java.awt.TrayIcon(image);
trayIcon.addActionListener(event -> Platform.runLater(this::showStage));
// if the user selects the default menu item (which includes the app name),
// show the main app stage.
java.awt.MenuItem openItem = new java.awt.MenuItem("Start QCap");
openItem.addActionListener(event -> Platform.runLater(this::showStage));
// the convention for tray icons seems to be to set the default icon for opening
// the application stage in a bold font.
java.awt.Font defaultFont = java.awt.Font.decode(null);
java.awt.Font boldFont = defaultFont.deriveFont(java.awt.Font.BOLD);
openItem.setFont(boldFont);
java.awt.MenuItem settingsItem = new java.awt.MenuItem("Settings");
settingsItem.addActionListener(event -> Platform.runLater(this::showSettings));
java.awt.MenuItem CheckForUpdatesItem = new java.awt.MenuItem("Check for Updates");
CheckForUpdatesItem.addActionListener(event -> {
try {
Desktop.getDesktop().browse(new URI(Constants.CHECK_FOR_UPDATES_URL));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
});
java.awt.MenuItem helpItem = new java.awt.MenuItem("Help");
helpItem.addActionListener(event -> {
try {
Desktop.getDesktop().browse(new URI(Constants.HELP_URL));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
});
java.awt.MenuItem aboutUSItem = new java.awt.MenuItem("About Us");
aboutUSItem.addActionListener(event -> {
try {
Desktop.getDesktop().browse(new URI(Constants.ABOUT_US_URL));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
});
// to really exit the application, the user must go to the system tray icon
// and select the exit option, this will shutdown JavaFX and remove the
// tray icon (removing the tray icon will also shut down AWT).
java.awt.MenuItem exitItem = new java.awt.MenuItem("Exit");
exitItem.addActionListener(event -> exit());
// setup the popup menu for the application.
final java.awt.PopupMenu popup = new java.awt.PopupMenu();
popup.add(openItem);
popup.add(settingsItem);
popup.addSeparator();
popup.add(CheckForUpdatesItem);
popup.add(helpItem);
popup.add(aboutUSItem);
popup.addSeparator();
popup.add(exitItem);
trayIcon.setPopupMenu(popup);
// create a timer which periodically displays a notification message.
notificationTimer.schedule(new TimerTask() {
@Override
public void run() {
javax.swing.SwingUtilities.invokeLater(() -> trayIcon.displayMessage("QCap Notifiction",
"QCap app is running ", java.awt.TrayIcon.MessageType.INFO));
}
}, 5 * 60 * 1000, 5 * 60 * 1000);
tray.add(trayIcon);
} catch (java.awt.AWTException | IOException e) {
System.out.println("Unable to init system tray");
e.printStackTrace();
}
}
void exit() {
notificationTimer.cancel();
Platform.exit();
tray.remove(trayIcon);
exitCallback.run();
System.exit(0);
}
/**
* Shows the application stage and ensures that it is brought ot the front of
* all stages.
*/
private void showStage() {
if (stage != null) {
stage.show();
stage.toFront();
stage.setIconified(false);
stage.setAlwaysOnTop(true);
stage.setAlwaysOnTop(false);
}
}
private void showSettings() {
if (isAuthenticated()) {
if (settingsStage == null) {
settingsStage = new Stage();
}
settingsStage.setScene(createLoginContent());
settingsStage.setTitle("Login/Settings");
settingsStage.show();
settingsStage.toFront();
settingsStage.setIconified(false);
}
}
public void hideSettings() {
if (settingsStage != null) {
settingsStage.hide();
}
}
// public static void main(String[] args) throws IOException,
// java.awt.AWTException {
// launch(args);
// }
public void setStage(Stage stage) {
this.stage = stage;
}
public boolean isAuthenticated() {
return authenticated;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public boolean isRememberChk() {
return rememberChk;
}
public void setRememberChk(boolean rememberChk) {
this.rememberChk = rememberChk;
}
public boolean isStartQCapAtLogin() {
return StartQCapAtLogin;
}
public void setStartQCapAtLogin(boolean startQCapAtLogin) {
StartQCapAtLogin = startQCapAtLogin;
}
}