Spring-Delete-Methode wird nicht unterstütztJava

Java-Forum
Anonymous
 Spring-Delete-Methode wird nicht unterstützt

Post by Anonymous »

Ich habe ein Problem mit der Löschmethode. Andere Methoden sind in Ordnung, aber beim Löschen stimmt etwas nicht. Es zeigt mir: Die Anforderungsmethode „DELETE“ wird nicht unterstützt.
Meine Anfrage an Postman ist http://localhost:8080/v1/tasks/1 mit einer Löschoption. Irgendwelche Ideen?

Code: Select all

@Service
public class DbService {
@Autowired
private TaskRepository repository;

public void deleteTask(final Long id) throws TaskNotFoundException {
Task task = repository.findById(id).orElseThrow(TaskNotFoundException::new);
repository.deleteById(id);
}
Schnittstelle

Code: Select all

@Repository
public interface TaskRepository extends CrudRepository {

@Override
void deleteById(Long id);

}
Verantwortlicher

Code: Select all

@DeleteMapping(value = {"taskId"})
public ResponseEntity deleteTask(@PathVariable Long taskId) throws TaskNotFoundException {
service.deleteTask(taskId);
return ResponseEntity.ok("Deleted succesfully" + taskId);
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post