title: Disable csrf using Java configuration
body: <p>Good Day,</p>
  
  <p>I am trying to learn Spring.
  I am currently doing this guide: <a href="http://spring.io/guides/gs/consuming-rest/" rel="nofollow">http://spring.io/guides/gs/consuming-rest/</a></p>
  
  <p>I have followed all instructions, however, when I try to run the application,
  403 Forbidden is displayed.</p>
  
  <p>I searched the net and found out that it is due to the csrf protection.
  And so, I proceeded to search the net how to disable csrf.
  Here is my Java configuration:</p>
  
  <pre><code>@EnableWebSecurity
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
              .csrf().disable();
      }
  }
  </code></pre>
  
  <p>My question is, how do I use this configuration?
  Specifically, at which part of the code should I insert it?</p>
  
  <p>Here are the other 2 classes as stated in the tutorial. All of them belong to the same package (Hello).</p>
  
  <pre><code>@JsonIgnoreProperties(ignoreUnknown = true)
  public class Page {
      private String name;
      private String about;
      private String phone;
      private String website;
  
      public String getName() {
          return name;
      }
  
      public String getAbout() {
          return about;
      }
  
      public String getPhone() {
          return phone;
      }
  
      public String getWebsite() {
          return website;
      }
  }
  
  public class Application {
  
      public static void main(String[] args) {
          RestTemplate restTemplate = new RestTemplate();
          Page page = restTemplate.getForObject("http://graph.facebook.com/pivotalsoftware", Page.class);
          System.out.println("Name:       " + page.getName());
          System.out.println("About:      " + page.getAbout());
          System.out.println("Phone:      " + page.getPhone());
          System.out.println("Website:    " + page.getWebsite());
      }
  
  }
  </code></pre>