'Spring MVC with HATEOAS

I use Spring MVC (no Spring Boot) with HATEOAS in order to get HAL-FORMS with Affordance response like this:

      "_links": {
        "index": {
          "href": "/api"
           ...
        }

But i still get the JSON format:

      "links": [
            {
              "href": "/api"   
            }
           ...
          ]

In my code I already use:

    @RestController
    @EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL_FORMS)
    public class myController {...}
        @GetMapping(value = "/api", produces = { "application/prs.hal-forms+json" })
        ResponseEntity<EntityModel<E>> get(Object object) {...}

        <dependency>
            <groupId>org.springframework.hateoas</groupId>
            <artifactId>spring-hateoas</artifactId>
            <version>1.4.1</version>
        </dependency>


      <!-- Configure to plugin JSON as request and response in method handler -->
        <beans:bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
            <beans:property name="messageConverters">
                <beans:list>
                    <beans:ref bean="jsonMessageConverter"/>
                </beans:list>
            </beans:property>
        </beans:bean>
        
        <!-- Configure bean to convert JSON to POJO and vice versa -->
        <beans:bean id="jsonMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
        </beans:bean>   

What am I missing?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source