title: Spring Boot Static Resources
body: <p>I am trying to create a Spring Boot with Mvc and AngularJs. I modified the View Resolver of my app so I can point my application to look on the "WEB-INF/pages/" folder for my static html files. Now on the html file I declared the source of my AngularJs libraries by using the webjars dependency</p>
  
  <pre><code>&lt;script src="webjars/angularjs/1.5.5/angular.min.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I know that in order to make this work is I have to declare the classpath of the webjars libray on the application's ResourceHandlerRegistry so on my configuration file I added only this line of code</p>
  
  <pre><code>@Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
  }
  </code></pre>
  
  <p>After adding this line my code somehow works but what makes me curious is that about this line on my html file</p>
  
  <pre><code>&lt;script src="resources/js/angular/app.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I noticed that on a Spring MVC application that in order for Spring to detect the Javascript files under the webapp's resource folder is that we have to declare that folder on the <code>ResourceHandlerRegistry</code> just like this</p>
  
  <pre><code>public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
  }
  </code></pre>
  
  <p>but I haven't declared my webapp's resource folder on my Spring Boot's <code>ResourceHandlerRegistry</code>but still the application can see my app.js file and my AngularJs codes still works. Here is the file structure of my Application</p>
  
  <p><code>src
  |--main
       |--java
       |--resources
       |--webapp
            |--resources
                 |--js
                     |--angular
                          |--app.js
            |--WEB-INF
                 |--index.html</code></p>