Вызвано: java.lang.ClassNotFoundException: org.apache.hc.client5.http.classic.HttpClientJAVA

Программисты JAVA общаются здесь
Anonymous
Вызвано: java.lang.ClassNotFoundException: org.apache.hc.client5.http.classic.HttpClient

Сообщение Anonymous »

Чтобы решить ту же проблему, что и здесь, запрос RestTemplate PATCH в моем приложении Spring-Boot 3

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

org.springframework.web.client.ResourceAccessException: I/O error on PATCH request for "http://localhost:8080/people/1":Invalid HTTP method: PATCH; nested exception is java.net.ProtocolException: Invalid HTTP method: PATCH
Я делаю то же самое, что и в принятом ответе:

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

@Configuration
class TestRestTemplateConfig {

@Bean
fun testRestTemplate(restTemplateBuilder: RestTemplateBuilder): TestRestTemplate {
val testRestTemplate = TestRestTemplate(restTemplateBuilder, null, null, null)
testRestTemplate.restTemplate.requestFactory = HttpComponentsClientHttpRequestFactory()
return testRestTemplate
}
}
Также у меня есть зависимость:

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

implementation("org.apache.httpcomponents:httpclient:4.5.14")
Но когда я начинаю тест, я вижу ошибку:

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

Caused by: java.lang.ClassNotFoundException: org.apache.hc.client5.http.classic.HttpClient
Но если я попытаюсь найти этот класс в своей IDE, я смогу это сделать:
Изображение

Я пытался выполнить команду gradle clean, но безуспешно. Я в замешательстве.

Подробнее здесь: https://stackoverflow.com/questions/767 ... tp-classic

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