title: How to configure a custom RelProvider for Spring HATEOAS when using Spring Boot?
body: <p>I'm using the party model:</p>
  
  <pre><code>@Entity
  @Inheritance(strategy=...)
  @JsonTypeInfo(use= JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
  @DiscriminatorColumn(name = "type")
  public abstract class Party {
  
    @Column(updatable = false, insertable = false)
    private String type;
  
    ...
  }
  
  @Entity
  public class Individual extends Party {
    ...
  }
  
  @Entity class Organization extends Party {
    ...
  }
  </code></pre>
  
  <p>Spring Data REST responds like this:</p>
  
  <pre><code>{
    "_embedded": {
      "organizations": [
        {
          "type":"Organization",
          "name": "Foo Enterprises",
          "_links": {
            "self": {
              "href": "http://localhost/organization/2"
            },
            "organization": {
              "href": "http://localhost/organization/2"
            }
          }
        }
      ],
      "individuals": [
        {
          "type":"Individual",
          "name": "Neil M",
          "_links": {
            "self": {
              "href": "http://localhost/individual/1"
            },
            "individual": {
              "href": "http://localhost/individual/1"
            }
          }
        }
      ]
    }
  }
  </code></pre>
  
  <p>But I need it to respond like this:</p>
  
  <pre><code>{
    "_embedded": {
      "parties": [
        {
          "type": "Organization",
          "name": "Foo Enterprises",
          "_links": {
            "self": {
              "href": "http://localhost/party/2"
            },
            "organization": {
              "href": "http://localhost/party/2"
            }
          }
        },
        {
          "type": "Individual",
          "name": "Neil M",
          "_links": {
            "self": {
              "href": "http://localhost/party/1"
            },
            "individual": {
              "href": "http://localhost/party/1"
            }
          }
        }
      ]
    }
  }
  </code></pre>
  
  <p>To do so, I understand I <a href="https://jira.spring.io/browse/DATAREST-344" rel="noreferrer">need to provide a custom RelProvider</a>:</p>
  
  <pre><code>@Order(Ordered.HIGHEST_PRECEDENCE)
  @Component
  public class MyRelProvider implements RelProvider {
  
      public MyRelProvider() {}
  
      @Override
      public String getItemResourceRelFor(Class&lt;?&gt; aClass) {
          return "party";
  
      }
  
      @Override
      public String getCollectionResourceRelFor(Class&lt;?&gt; aClass) {
          return "parties";
      }
  
      @Override
      public boolean supports(Class&lt;?&gt; aClass) {
          return aClass.isAssignableFrom(Party.class);
      }
  }
  </code></pre>
  
  <p>I tried configuring it in Application.java:</p>
  
  <pre><code>@SpringBootApplication
  public class Application {
  
      public static void main(String[] args) throws Exception {
          SpringApplication.run(Application.class, args);
      }
  
      @Bean
      RelProvider myRelProvider() {
          return new MyRelProvider();
      }
  }
  </code></pre>
  
  <p>This doesn't work though. It seems to not get registered, or get registered correctly. See <a href="http://andreitsibets.blogspot.ca/2014/04/hal-configuration-with-spring-hateoas.html" rel="noreferrer">http://andreitsibets.blogspot.ca/2014/04/hal-configuration-with-spring-hateoas.html</a> </p>
  
  <p>How can I fix this?</p>