我在資源文件夾下的java項目中有資源。當我使用下面的方法[2]來加載它正在工作的資源。但是當我在野蠻9.x部署我的戰爭時,它說找不到file.avsc文件。 它給出類路徑爲[1];我如何加載jboss war中的資源文件?如何在jboss war中加載資源文件 - wildfly9.xV
[1]
java.io.FileNotFoundException:/content/ratha.war/WEB-INF/lib/core-0.0.1-SNAPSHOT.jar/avro_schemas/file.avsc(沒有這樣的文件或目錄)
[2]
ClassLoader classLoader = getClass().getClassLoader();
ClassLoader classLoader = this.getClass().getClassLoader();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
File file = new File(classLoader.getResource("avro_schemas/file.avsc").getFile());
謝謝你的作品.. – Ratha