Probleme de path

Fermé
jgordinho Messages postés 2 Date d'inscription mardi 25 février 2020 Statut Membre Dernière intervention 4 mars 2020 - Modifié le 4 mars 2020 à 17:09
Bonjour communauté , suis nouveau programmeur en java , spring boot , j'arrive pas a maitriser les chemins ( path) en springboot . J'aimerais bien quil fonctionne mais rien ne s'affiche . Aidez moi .

dans mon navigateur jai mis : http://localhost:8080/avion/ListAvion

voici mon code back :

package com.aviation.controllers;

import java.util.List;

import javax.websocket.server.PathParam;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.aviation.entities.Avion;
import com.aviation.repositories.AvionRepository;

@RestController
@RequestMapping(value="/avion")
public class AvionController {

 @Autowired
 private AvionRepository avionRepository;
 
 private static final Logger LOGGER = LoggerFactory.getLogger(AvionController.class);

 // enregistrer un avion ds la bd

 @PostMapping(value = "/saveAvion")
 public Avion saveAvion(Avion a) {

  Avion retour = null;

  try {

   retour = avionRepository.save(a);

  } catch (Exception e) {
   e.getMessage();
  }

  return retour;

 }

 // retourne la liste des avions
 @GetMapping(value = "/ListAvion")
 public List<Avion> ListAvion() {

  List<Avion> retour = null;

  try {

  } catch (Exception e) {

   retour = avionRepository.findAll();
  }

  return retour;
 }
 

 // retourne un avion
 @GetMapping(value = "/findone/{id}")
 public Avion findone(@PathParam("id") Long id) {

  Avion retour = null;

  try {

   retour = avionRepository.findById(id).orElse(null);

  } 
  
  catch (Exception e) {

   e.getMessage();
  }

  return retour;
 }
 
 
 // Update  avion
  @PostMapping(value = "/updateAvion")
  public Avion updateAvion(Avion av) {
   
   
   Avion a = null ;
   Avion retour = null;

   try {
    
    a = findone(av.getIdAvion());
    
    if (a!= null) {
     
     retour = avionRepository.save(a);
     
    }

   } catch (Exception e) {

    e.getMessage();
   }

   return retour;
  }

}