amarmicrodev / mcommerce-partie1 Goto Github PK
View Code? Open in Web Editor NEWCode pour la première partie du cours d'architecture MS
Code pour la première partie du cours d'architecture MS
La sequence n'a pas été mise à jour après les insertions des 3 lignes au démarrage de l'application.
Il faut remplacer le fichier data.sql par ce contenu :
-- http://h2database.com/html/main.html ------------------------- -- For H2 Database only ------------------------- INSERT INTO product VALUES(1, 'Ordinateur portable' , 350, 120); INSERT INTO product VALUES(2, 'Aspirateur Robot' , 500, 200); INSERT INTO product VALUES(3, 'Table de Ping Pong' , 750, 400); ALTER SEQUENCE HIBERNATE_SEQUENCE RESTART WITH 4
Solution :
Dans le pom.xml modifier la version de spring-boot-starter-parent (la 2.2.0.RELEASE fonctionne pour moi). Modifier également la dépendance de spring-boot-starter-test ainsi 👍
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
Dans ProductController.java, remplacer "productDao.delete(id);" par "productDao.deleteById(id);"
Modifier la classe de test comme suit :
@SpringBootTest
public class MicrocommerceApplicationTests {
@Test
public void contextLoads() {
}
... et modifier les imports (supprimer ceux qui sont obsolètes)
Le projet ne démarre plus : j'ai proposé une nouvelle version du package "spring-boot-starter-parent" afin de ne plus avoir le problème.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Cependant, il y a un impact dan le ProductController sur la méthode delete(id) : il faut passer l'objet product lequel contient l'id en paramètre dorénavant delete(product).
Pour réaliser une suppression par le biais de l'id, préférer deleteById(id).
Cela implique de modifier un poil le cours, mais c'est mieux que de fournir une TP qui ne fonctionne plus et un cours qui commence à montrer des choses qui ne fonctionne plus.
Idem, pour cette annotation Swagger :
@Api( description="API pour es opérations CRUD sur les produits.")
le description= est marqué comme Deprecated
=> ceci fonctionne :
@Api("API pour des opérations CRUD sur les produits.")
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.