カスタムの場所からリソースを取得:春ブーツは、私は自分のアプリケーションのカスタムリソースハンドラは次のように設定されている
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/external/**")
.addResourceLocations("file:" + sharedResourceRootPath);
}
私はリソースを取得する方法を見つけることができません
@Value("${spring.configurateur.data}")
private String sharedResourceRootPath;
// with spring.configurateur.data: C:/webapp/data
私のマッピングこの場所の下で私のコード:
try(InputStream ir = ResourceUtils.getURL("external", "parentDir", "conf.csv").openStream();) {......}
が見つかりません...
java.io.FileNotFoundException: D:\external\parentDir\conf.csv (Le chemin d’accès spécifié est introuvable)
あなたは 'Cの下にファイルを取得したいですか:\ webappの外部\ parentDir \ conf.csv' \データ\?または、正確にどのファイルですか? 'Paths.get(...)'は、ファイルシステムのルートで始まらない場合、現在のディレクトリからの相対パスを作成するためです。 –
はいファイルC:\ webapp \ data \ parentDir \ conf.csvを取得したいと思います。私は質問を編集し、Paths.getの部分を削除しました。 Thx – uncleBounty