title: How correctly to use external files in Spring MVC?
body: <p>I can't access files that are not stored in <code>src/main/</code> project path</p>
  
  <p><strong>Project structure:</strong> <br>
  <a href="https://i.stack.imgur.com/yKyGi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yKyGi.png" alt="Project tree"></a></p>
  
  <p>Now I can access all files from <code>webapp/resources</code> but can't access files from userResources folder</p>
  
  <p><strong>Spring resourceHandler:</strong><br></p>
  
  <pre><code>@EnableWebMvc
  @Configuration
  public class AppConfig extends WebMvcConfigurerAdapter {
   //some configs
  
     @Override
     public void addResourceHandlers(ResourceHandlerRegistry registry) {
         registry.addResourceHandler("/resource/**").addResourceLocations("/resources/");
         registry.addResourceHandler("/vendors/**").addResourceLocations("/vendors/");
         //this line won't work
         registry.addResourceHandler("/userResources/**").addResourceLocations(
          "home/pika/workspace/Spring/Bookmarks/userResources")
         );
     }
  }
  </code></pre>
  
  <p>In view </p>
  
  <pre><code>&lt;img class="fb-image-lg" src="/home/pika/workspace/Spring/Bookmarks/userResources/admin/profile/wallImage.png" alt="Profile wall image" align="left"&gt;
  </code></pre>
  
  <p><strong>Image not found</strong>, I try to change src with: "/userResources/admin/profile/wallImage.png" anyway it doesn't work</p>
  
  <pre><code>&lt;img class="fb-image-profile thumbnail" src="/resources/images/defaultProfilePhoto.png" alt="Profile face image" align="left"&gt;
  </code></pre>
  
  <p><strong>Found image.</strong></p>
  
  <p>What I'm doing wrong?</p>
  
  <p><strong>PS</strong> <a href="https://github.com/gvart/Bookmarks" rel="nofollow noreferrer">Github repo</a> may it helps you to understand project structure</p>