Maven war プロジェクトでは、jetty-maven-plugin を開発コンテナとして使用しています。
いくつかのリソース ファイルをフィルター処理しました。具体的には、「bddconf.xml」という名前にしましょう。
このファイルは maven によってフィルタリングされ、target/classes ディレクトリに配置されます。
このスニペットを使用して、このファイルの後に古い自家製の bdd fwk 検索を実行します。
Properties properties = new Properties();
InputStream inputstream = properties.getClass().getResourceAsStream("/bddconf.xml");
このスニペットを webapp (jetty) で実行すると、inputStream が null になります。
一方、このスニペットでは、同じメソッドで:
import com.google.common.io.Resources;
String file = Resources.getResource("bddconf.xml").getFile();
File file2 = new File(file);
logger.info("Does bdd file exists : [" + file2.exists() + "] file : [" + file2.toString() + "]");
// Does bdd file exists : [true] file : [..path..\target\classes\bbdconf.xml]
動作しますが、この 2 つの方法の違いは何ですか?