У меня есть проект на основе maven в редакторе идей Intellij. Я использую javafx-maven-plugin. Моя цель - развернуть мой проект как файл EXE или MSI. Поскольку это первый раз с использованием maven, plz помогите мне сделать правильную конфигурацию для файла pom.xml. Или есть другой способ, отличный от maven, который может помочь мне достичь моей цели. Поэтому не стесняйтесь упоминать об этом.Javafx maven deployemnt под Intellij Idea
Итак, это мой pom.xml
<?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.abdo.EntrepriseLimted</groupId>
<artifactId>EntrepriseLimited</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>ENTREPRISELIMITED</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.2.0</version>
<configuration>
<mainClass>MainApplication</mainClass>
<verbose>true</verbose>
<vendor>Abdo</vendor>
</configuration>
<executions>
<execution>
<!-- required before build-native -->
<id>create-jfxjar</id>
<phase>package</phase>
<goals>
<goal>build-jar</goal>
</goals>
</execution>
<execution>
<id>create-native</id>
<phase>package</phase>
<goals>
<goal>build-native</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources/fxml</directory>
</resource>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>8.40.10</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1206-jdbc42</version>
</dependency>
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>jfxtras-labs</artifactId>
<version>8.0-r4</version>
</dependency>
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>jfxtras-controls</artifactId>
<version>8.0-r4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.16</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.16</version>
</dependency>
</dependencies>
</project>
После выполнения этой pom.xml с помощью com.zenjava: JavaFX-Maven-плагин: JFX-банку. я получаю этот результат, показывающий этот результат:
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ EntrepriseLimited ---
[INFO] Building jar: D:\Projects\6.Project SI limted\2 nd iteration\2. Object Oriented design\target\EntrepriseLimited-1.0.jar
[INFO]
[INFO] <<< javafx-maven-plugin:8.2.0:jar (default-cli) @ EntrepriseLimited <<<
[INFO]
[INFO] --- javafx-maven-plugin:8.2.0:jar (default-cli) @ EntrepriseLimited ---
[INFO] Building JavaFX JAR for application
[INFO] Adding 'deploy' directory to Mojo classpath: D:\Projects\6.Project SI limted\2 nd iteration\2. Object Oriented design/src/main/deploy
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.316s (Wall Clock)
[INFO] Finished at: Tue Mar 01 13:04:24 WAT 2016
[INFO] Final Memory: 25M/226M
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
Похоже, что проект был успешно развернут, но: под целевой каталог я получаю имя файла «EntrepriseLimited-1.0.jar», после того, как дважды щелкните файл не работает. под target/jfx/i get EntrepriseLimited-1.0-jfx.jar под target/jfx/lib я вижу зависимости. после двойного нажатия на файл «ntrepriseLimited-1.0-jfx.jar» он не работает.
Вот основной код приложения:
public class MainApplication extends Application {
private Stage primaryStage = null;
@Override
public void start(Stage primaryStage) throws Exception {
this.primaryStage = primaryStage;
buildMainWindow();
}
private void buildMainWindow() {
FXMLLoader loader = new FXMLLoader();
Parent parent = new AnchorPane();
System.out.println(getClass().getResource(""));
loader.setLocation(getClass().getResource("fxml/mainWindow.fxml"));
loader.setRoot(parent);
try {
parent = (AnchorPane) loader.load();
} catch (IOException e) {
e.printStackTrace();
}
Scene sc = new Scene(parent);
primaryStage.setScene(sc);
primaryStage.centerOnScreen();
primaryStage.show();
}
public void setPrimaryStage(Stage stage) {
this.primaryStage = stage;
}
public Stage getPrimaryStage() {
return primaryStage;
}
public static void main(String[] args) {
launch(args);
}
}
И она представляет собой контроллер для MainWindow, где я открывать новые окна, на основании пользовательского действий:
public class MainWindowController implements Initializable {
// Tabbed pane
@FXML
private TabPane tbTabPaneHome;
@Override
public void initialize(URL location, ResourceBundle resources) {
}
private void createTab(String title, AnchorPane parent) {
Tab tab = new Tab(title);
for (Tab child : tbTabPaneHome.getTabs()) {
if (child.getText().equals(title)) {
tbTabPaneHome.getSelectionModel().select(child);
return;
}
}
tab.setContent(parent);
tbTabPaneHome.getTabs().addAll(tab);
tbTabPaneHome.getSelectionModel().select(tab);
}
private Parent loadContent(URL resources) {
try {
FXMLLoader loader = new FXMLLoader();
Parent parent = new AnchorPane();
loader.setLocation(resources);
parent = loader.load();
return parent;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private AnchorPane buildEntrepriseTab() {
AnchorPane parent = (AnchorPane) loadContent(getClass()
.getResource("../fxml/entreprise/entreprise.fxml"));
return parent;
}
private AnchorPane buildTransactionTab() {
AnchorPane parent = (AnchorPane) loadContent(getClass()
.getResource("../fxml/transaction/transaction.fxml"));
return parent;
}
private AnchorPane buildAccountTab() {
AnchorPane parent = (AnchorPane) loadContent(getClass()
.getResource("../fxml/account/account.fxml"));
return parent;
}
private AnchorPane buildTypeOfTransactionTab() {
AnchorPane parent = (AnchorPane) loadContent(getClass()
.getResource("../fxml/TypeOfTransaction.fxml"));
return parent;
}
private AnchorPane buildUserTab() {
AnchorPane parent = (AnchorPane) loadContent(getClass()
.getResource("../fxml/user/user.fxml"));
return parent;
}
// Event Handling
// Action events
@FXML
public void listDesEntrepriseClicked() {
createTab("Entreprise", buildEntrepriseTab());
}
@FXML
public void listTransactionClicked() {
createTab("Transaction", buildTransactionTab());
}
@FXML
public void listTypeOfTransactionClicked() {
createTab("TypeOfTransaction", buildTypeOfTransactionTab());
}
@FXML
public void listAccountClicked() {
createTab("Compte", buildAccountTab());
}
@FXML
public void listUserClicked() {
createTab("Utilisateur", buildUserTab());
}
}
Я только обычно работают на жидком создать ехе и если будет найден в мишени под 'JFX// {имя-проекта} родной - $ {PROJECT-verions}' – hotzst
как настроить pom.xml –