|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th width="200px"><h6>[:rewind: Exo Précédent](/Exo14-MVC/1%5D-Code-Java)</h6></th>
|
|
|
|
<th colspan="8" width="600px"><h1 align="center">15 - Spring - MVC - Rest</h1></th>
|
|
|
|
<th width="200px"><h6 align="right">[Exo Suivant :fast_forward:](/Exo16-HATEOAS/1%5D-Code-Java)</h6></th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td> </td>
|
|
|
|
<td align="center">:white_check_mark:<br/>Code Java</td>
|
|
|
|
<td align="center">[:two:](/Exo15-Rest/2%5D-XML)<br/>XML</td>
|
|
|
|
<td align="center">[:three:](/Exo15-Rest/3%5D-Configuration)<br/>Configuration</td>
|
|
|
|
<td align="center">[:four:](/Exo15-Rest/4%5D-Spring-Boot)<br/>Spring Boot</td>
|
|
|
|
<td align="center">[:five:](/Exo15-Rest/5%5D-Gestion-du-Json)<br/>Gestion du Json</td>
|
|
|
|
<td align="center">[:six:](/Exo15-Rest/6%5D-Gestion-des-exceptions)<br/>Gestion des exceptions</td>
|
|
|
|
<td align="center">[:seven:](/Exo15-Rest/7%5D-Controleurs)<br/>Contrôleurs</td>
|
|
|
|
<td align="center">[:eight:](/Exo15-Rest/8%5D-Tests)<br/>Tests</td>
|
|
|
|
<td> </td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
|
|
|
|
<tfoot>
|
|
|
|
<tr align="right">
|
|
|
|
<td colspan="10">
|
|
|
|
<h6>:copyright: 2019 - <a href="mailto:admin@ferretrenaud.fr">FERRET Renaud</a></h6>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tfoot>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
***
|
|
|
|
|
|
|
|
# Importation du projet dans Eclipse
|
|
|
|
|
|
|
|
Dans le menu Eclipse, sélectionnez `File/Import` puis `Existing Maven Projects`
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
Pointez vers le dossier existant `formation.spring\exercices\enonces\Exo15-Rest`.
|
|
|
|
|
|
|
|
Nous sommes toujours en JEE.
|
|
|
|
|
|
|
|
Dans cet exercice nous allons récupérer un projet réalisé en [Web Service Rest](https://fr.wikipedia.org/wiki/Representational_state_transfer) respectant l'architecture [MVC](http://sametmax.com/quest-de-que-mvc-et-a-quoi-ca-sert/).
|
|
|
|
|
|
|
|
Le back du projet est déjà en Spring, le front par contre reste à faire. Les contrôleurs sont des [Web Service Rest](https://fr.wikipedia.org/wiki/Representational_state_transfer). La différence avec les JSPs est la suivante :
|
|
|
|
* une JSP est une page web construite dynamiquement côté serveur puis renvoyée au client.
|
|
|
|
* un web service est une forme de *servlet* qui renvoie au client un flux (binaire, XML, JSon = pas une page). Puis le client construit sa page en fonction du flux reçu.
|
|
|
|
|
|
|
|
[JPA](https://www.jmdoudoux.fr/java/dej/chap-jpa.htm) est une norme, nous utilisons Hibernate 5 comme implémentation (voir exercices [13](/Exo13)).
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
Le projet est en Maven et contient toutes les dépendances nécessaires au projet (y compris celles du Spring).
|
|
|
|
Attendez que toutes les dépendances soient téléchargées d'Internet avant de modifier le projet.
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
Vérifiez que tout fonctionne (pas de rouge sur le projet). **Le cas échéant**, vérifiez que vous avez un accès Internet puis faites un clic droit sur le projet puis `Maven - Update Project ...` et cochez `Force Update of Snapshots/Releases`.
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
Si besoin, réinitialisez la base de données avec le scripte `db\banque_mysql.sql`.
|
|
|
|
|
|
|
|
Potentiellement, modifiez le/les fichiers ciblant les informations (login/password) pour accéder à la base de données :
|
|
|
|
* `src\main\webapp\META-INF\context.xml`
|
|
|
|
* `src\test\resources\spring\test-database.properties` (si en XML ou @Configuration)
|
|
|
|
* `src\test\resources\application-test.properties` (si en Spring Boot)
|
|
|
|
* `src\main\resources\application-auto.properties` (si en Spring Boot)
|
|
|
|
|
|
|
|
***
|
|
|
|
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th width="200px"><h6>[:rewind: Exo Précédent](/Exo14-MVC/1%5D-Code-Java)</h6></th>
|
|
|
|
<th colspan="8" width="600px"><h1 align="center">15 - Spring - MVC - Rest</h1></th>
|
|
|
|
<th width="200px"><h6 align="right">[Exo Suivant :fast_forward:](/Exo16-HATEOAS/1%5D-Code-Java)</h6></th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td> </td>
|
|
|
|
<td align="center">:white_check_mark:<br/>Code Java</td>
|
|
|
|
<td align="center">[:two:](/Exo15-Rest/2%5D-XML)<br/>XML</td>
|
|
|
|
<td align="center">[:three:](/Exo15-Rest/3%5D-Configuration)<br/>Configuration</td>
|
|
|
|
<td align="center">[:four:](/Exo15-Rest/4%5D-Spring-Boot)<br/>Spring Boot</td>
|
|
|
|
<td align="center">[:five:](/Exo15-Rest/5%5D-Gestion-du-Json)<br/>Gestion du Json</td>
|
|
|
|
<td align="center">[:six:](/Exo15-Rest/6%5D-Gestion-des-exceptions)<br/>Gestion des exceptions</td>
|
|
|
|
<td align="center">[:seven:](/Exo15-Rest/7%5D-Controleurs)<br/>Contrôleurs</td>
|
|
|
|
<td align="center">[:eight:](/Exo15-Rest/8%5D-Tests)<br/>Tests</td>
|
|
|
|
<td> </td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
|
|
|
|
<tfoot>
|
|
|
|
<tr align="right">
|
|
|
|
<td colspan="10">
|
|
|
|
<h6>:copyright: 2019 - <a href="mailto:admin@ferretrenaud.fr">FERRET Renaud</a></h6>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tfoot>
|
|
|
|
</table> |