我有一个使用maven进行构建的JavaFX项目。该项目使用资源区域设置文件。
所以,我已超过src/main/resources/locale/strings_xxx.properties
。
从IntelliJ运行时,此功能正常。但是,当我尝试使用maven构建一个jar文件时,它会抛出此异常:
Exception in Application start method
Caused by: java.util.MissingResourceException: Can't find bundle for base name locale\strings, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
at java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.util.ResourceBundle.getBundle(Unknown Source)
at com.test.SystemConfiguration.<clinit>(SystemConfiguration.java:16)
我的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.test</groupId>
<artifactId>testJFX</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160212</version>
</dependency>
<dependency>
<groupId>com.systray.test</groupId>
<artifactId>systray</artifactId>
<version>0.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/Systray.jar</systemPath>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<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>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.test.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
SystemConfiguration.java正在使用ResourceBundle:
private ResourceBundle bundle = ResourceBundle.getBundle("locale\\strings", Locale.getDefault());
请记住,IntelliJ运行此应用程序工作正常。我在这个pom中缺少什么?