Я звоню в другой API, используя Resttemplate, но он возвращает ошибку
Вот код < /p>
@Autowired
private RestTemplate restTemplate;
@Override
public User getUser(String userId) {
User user = userRepository.findById(userId).orElseThrow(() -> new ResourceNotFoundException("User with give id is not found on server !! " + userId));
//fetch rating for the above user from the RATING SERVICE
String url = "http://localhost:8083/ratings/users/ab2 ... b40f995dd5";
Array forObject = restTemplate.getForObject(url, Array.class);
//httpMessageConverter.canRead()
logger.info("{}", forObject);
return user;
}
< /code>
Exception is -
org.springframework.web.client.UnknownContentTypeException: Could not extract response: no suitable HttpMessageConverter found for response type [class java.lang.reflect.Array] and content type [application/json]
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:133) ~[spring-web-6.2.1.jar:6.2.1]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:903) ~[spring-web-6.2.1.jar:6.2.1]
< /code>
enter image description here
enter image description here
enter image description here
Подробнее здесь: https://stackoverflow.com/questions/793 ... ang-reflec
Нет подходящего httpmessageconverter для типа ответа [класс java.lang.reflect.array] и тип контента [Application/json] ⇐ JAVA
Программисты JAVA общаются здесь
1738220528
Anonymous
Я звоню в другой API, используя Resttemplate, но он возвращает ошибку
Вот код < /p>
@Autowired
private RestTemplate restTemplate;
@Override
public User getUser(String userId) {
User user = userRepository.findById(userId).orElseThrow(() -> new ResourceNotFoundException("User with give id is not found on server !! " + userId));
//fetch rating for the above user from the RATING SERVICE
String url = "http://localhost:8083/ratings/users/ab2573f5-1b25-41b3-b353-4eb40f995dd5";
Array forObject = restTemplate.getForObject(url, Array.class);
//httpMessageConverter.canRead()
logger.info("{}", forObject);
return user;
}
< /code>
Exception is -
org.springframework.web.client.UnknownContentTypeException: Could not extract response: no suitable HttpMessageConverter found for response type [class java.lang.reflect.Array] and content type [application/json]
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:133) ~[spring-web-6.2.1.jar:6.2.1]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:903) ~[spring-web-6.2.1.jar:6.2.1]
< /code>
enter image description here
enter image description here
enter image description here
Подробнее здесь: [url]https://stackoverflow.com/questions/79398999/no-suitable-httpmessageconverter-found-for-response-type-class-java-lang-reflec[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия