此计划不起作用:Platform.runLater(() -> Notifications.create().text("Hello!").showError());
如果在调用时抛出空指针。 例外:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException at org.controlsfx.control.Notifications$NotificationPopupHandler.show(Notifications.java:334) at org.controlsfx.control.Notifications$NotificationPopupHandler.show(Notifications.java:322) at org.controlsfx.control.Notifications.show(Notifications.java:269) at org.controlsfx.control.Notifications.showError(Notifications.java:253)
我明显感觉到这与maven有关,因为我一直使用controlsfx,但这是我第一次在maven环境中使用它。
POM:
<dependencies> <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.6</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.9.5</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-core</artifactId> <version>1.3</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.controlsfx/controlsfx --> <dependency> <groupId>org.controlsfx</groupId> <artifactId>controlsfx</artifactId> <version>8.40.14</version> </dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.opusconverter.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jackofall</shadedClassifierName> <!-- Any name that makes sense -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>