このコード行を使用してリンクを生成する場合:
indexResource.add(linkTo(IndexController.class).withSelfRel());
この JSON が生成されます。
{
"links" : [ {
"rel" : "self",
"href" : "http://localhost:8080"
} ]
}
ただし、Spring Data Rest によって生成されるリソース リンクは、次の JSON を生成します。
{
"_links" : {
"self" : {
"href" : "http://localhost:8080/persons{?page,size,sort}",
"templated" : true
}
}
}
特に、Spring Data Rest で作成されたものを真似したいと思います。どうすればいいですか?
次の構成で Spring Boot を使用しています。
@Configuration
@Import(RepositoryRestMvcConfiguration.class)
@EnableAutoConfiguration
@EnableJpaRepositories(repositoryFactoryBeanClass = EnversRevisionRepositoryFactoryBean.class)
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
@ComponentScan
public class Application { ... }
保持または削除@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
しても何も変わらないようです。
次のgradle依存関係もあります。
compile "org.springframework.boot:spring-boot-starter-data-rest"
compile "org.springframework.boot:spring-boot-starter-data-jpa"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-jetty"
compile "org.springframework.data:spring-data-envers:0.2.0.RELEASE"
compile "org.hibernate:hibernate-envers:4.3.6.Final"
runtime "mysql:mysql-connector-java:5.1.32"
testCompile "junit:junit"