Client fonctionnel communiquant avec tous les MS
This commit is contained in:
parent
f272e9baa8
commit
228f765e52
21 changed files with 618 additions and 11 deletions
|
|
@ -22,6 +22,7 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud.version>Finchley.M8</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
@ -42,6 +43,17 @@
|
|||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
|
@ -49,6 +61,18 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
@ -58,5 +82,16 @@
|
|||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package com.mproduits;
|
||||
|
||||
import com.mproduits.configurations.ApplicationPropertiesConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties
|
||||
public class MproduitsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.mproduits.configurations;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties("mes-configs")
|
||||
public class ApplicationPropertiesConfiguration {
|
||||
|
||||
private int limitDeProduits;
|
||||
|
||||
public int getLimitDeProduits() {
|
||||
return limitDeProduits;
|
||||
}
|
||||
|
||||
public void setLimitDeProduits(int limitDeProduits) {
|
||||
this.limitDeProduits = limitDeProduits;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
package com.mproduits.web.controller;
|
||||
|
||||
import com.mproduits.configurations.ApplicationPropertiesConfiguration;
|
||||
import com.mproduits.dao.ProductDao;
|
||||
import com.mproduits.model.Product;
|
||||
import com.mproduits.web.exceptions.ProductNotFoundException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
@ -17,6 +19,9 @@ public class ProductController {
|
|||
@Autowired
|
||||
ProductDao productDao;
|
||||
|
||||
@Autowired
|
||||
ApplicationPropertiesConfiguration appProperties;
|
||||
|
||||
// Affiche la liste de tous les produits disponibles
|
||||
@GetMapping(value = "/Produits")
|
||||
public List<Product> listeDesProduits(){
|
||||
|
|
@ -25,7 +30,9 @@ public class ProductController {
|
|||
|
||||
if(products.isEmpty()) throw new ProductNotFoundException("Aucun produit n'est disponible à la vente");
|
||||
|
||||
return products;
|
||||
List<Product> listeLimitee = products.subList(0, appProperties.getLimitDeProduits());
|
||||
|
||||
return listeLimitee;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
spring.application.name=microservice-produits
|
||||
|
||||
server.port 9001
|
||||
|
||||
#Configurations H2
|
||||
spring.jpa.show-sql=true
|
||||
spring.h2.console.enabled=true
|
||||
|
||||
#défini l'encodage pour data.sql
|
||||
spring.datasource.sql-script-encoding=UTF-8
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
spring.application.name=microservice-produits
|
||||
|
||||
spring.cloud.config.uri=http://localhost:9101
|
||||
Loading…
Add table
Add a link
Reference in a new issue