2
我想通過Traverson來使用Spring-Hateoas的休息服務,但是我遇到以下問題,我沒有在Web中找到任何內容。我使用Spring-Boot 1.1.10.RELEASE。使用Traverson的Spring-Hateoas客戶端
我的客戶呼叫看起來像如下:
...
final Traverson traverson = new Traverson(new URI("http://localhost:8080/bbsng-app-rest"), MediaTypes.HAL_JSON);
...
我也得到了以下問題:
java.lang.NoClassDefFoundError: Could not initialize class org.springframework.hateoas.client.Traverson
at at.compax.bbsng.client.mvc.client.service.BerufServiceImpl.findeAlleBerufe(BerufServiceImpl.java:41)
at at.compax.bbsng.client.mvc.rest.controller.BerufController$1.call(BerufController.java:25)
at at.compax.bbsng.client.mvc.rest.controller.BerufController$1.call(BerufController.java:1)
at org.springframework.web.context.request.async.WebAsyncManager$4.run(WebAsyncManager.java:316)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:745)
=====
相關配置:
POM:
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>
...
應用級:
@Configuration
@EnableHypermediaSupport(type = HAL)
@EnableAutoConfiguration
public class ApplicationClientMvc {
public static void main(final String[] args) {
SpringApplication.run(ApplicationClientMvc.class, args);
}
...
====
REST的應用程序響應時調用上述網址:
{
"link": null,
"_links":
{
"self":
{
"href": "http://localhost:8080/bbsng-app-rest"
},
"berufe":
{
"href": "http://localhost:8080/bbsng-app-rest/beruf"
},
"betriebe":
{
"href": "http://localhost:8080/bbsng-app-rest/betrieb"
},
"fachrichtungen":
{
"href": "http://localhost:8080/bbsng-app-rest/fachrichtung"
}
}
}
謝謝爲h elping。
只是無意中發現這個答案。如果這解決了問題,請隨時接受您自己的答案,這非常好。 –