Ошибка Angular6 / SpringMVC 415 (неподдерживаемый тип носителя) при выполнении запроса HTTP PUT
Я создаю веб-приложение на основе Angular/Spring MVC/Hibernate. В частности, я пытаюсь обновить запись в БД с помощью формы, отправляя HTTP-запрос PUT со стороны клиента на сервер, но я продолжаю получать ошибку 415, хотя я указал правильный заголовок для содержимого тип ожидаемого сервера, который является JSON. После есть мой код. Заранее спасибо.
HTTP-вызов внешнего интерфейса (из dataService.ts)
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json'})
};
[...]
//Consulente - updateConsulente
updateConsulente(consulente: Consulente): Observable<Consulente> {
return this.http.put(this.backendUrl + "/updateConsulente", consulente, httpOptions)
.pipe(catchError(this.handleError));
}
Резервное копирование (из Java-файла контроллера)
@PutMapping(value = "/updateConsulente", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Consulente> updateConsulente(@RequestBody Consulente consulente) {
consulenteService.aggiornaConsulente(consulente);
Consulente c = consulenteService.findById(consulente.getIdConsulente());
return new ResponseEntity<Consulente>(c, HttpStatus.OK);
}
Я прекрасно знаю, что этот вопрос задавался много, я читал все это, пытаясь решить эту проблему, но пока ничего не получалось.
ОБНОВИТЬ
Занимаясь серфингом в интернете, я понял, что проблема может быть связана с ошибкой отсутствия зависимости от Джексона, поэтому я также включаю мои текущие сообщения о делах, если кто-то может указать на то, что отсутствует какой-либо компонент, я был бы очень благодарен.
<!-- Json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.7.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-media-json-jackson -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.27</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider -->
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.9.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.jaxrs/jackson-jaxrs-base -->
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-base</artifactId>
<version>2.9.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-jaxb-annotations -->
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<version>2.9.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.ext/jersey-entity-filtering -->
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-entity-filtering</artifactId>
<version>2.27</version>
</dependency>