Org.springframework.web.reactive.function.UnsupportedMediaTypeException: тип контента «application/json;charset=UTF-8» нJAVA

Программисты JAVA общаются здесь
Гость
Org.springframework.web.reactive.function.UnsupportedMediaTypeException: тип контента «application/json;charset=UTF-8» н

Сообщение Гость »


Ошибка появляется, когда мой код выглядит следующим образом:

Код: Выделить всё

@Test
public void getTemplateByIdTest() throws Exception {
client.get().uri("/template/getTemplate/7")
.exchange()
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON_UTF8)
.expectBody(VtTemplateVO.class)
.returnResult();
}
When I change my code like this,it's ok!

Код: Выделить всё

@Test
public void getTemplateByIdTest() throws Exception {
client.get().uri("/template/getTemplate/7")
.exchange()
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON_UTF8)
.expectBody(String.class)
.returnResult();
}
Why when I use

Код: Выделить всё

.expectBody(VtTemplateVO.class)
it will say

Код: Выделить всё

org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'application/json;charset=UTF-8' not supported
Somebody knows? please help,thanks


Источник: https://stackoverflow.com/questions/515 ... on-content

Вернуться в «JAVA»