Add external resources folder to Spring Boot

前端 未结 2 1180
时光说笑
时光说笑 2021-01-04 12:16

I\'d like to add a resource folder relative to the location of the jar (in addition to packaged resources within my jar), for example:

/Directory
    Applica         


        
2条回答
  •  花落未央
    2021-01-04 12:44

     @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry
                .addResourceHandler("/files/**")
                .addResourceLocations("file:/location1/", "file:/location2/");
    }
    

    access file using http://localhost:{port}/files/image.png

提交回复
热议问题