Skip to content

Commit fd752d3

Browse files
author
aldo
committed
Basic proyects working without eureka
1 parent 7b2aa95 commit fd752d3

47 files changed

Lines changed: 641 additions & 575 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/
58.5 KB
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
Lines changed: 14 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

springboot-servicio-item/pom.xml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>org.springframework.boot</groupId>
6+
<artifactId>spring-boot-starter-parent</artifactId>
7+
<version>2.3.12.RELEASE</version>
8+
<relativePath /> <!-- lookup parent from repository -->
9+
</parent>
10+
<!--version>2.7.12</version>-->
11+
<groupId>com.formacionbdi.springboot.app.item</groupId>
12+
<artifactId>springboot-servicio-item</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<name>springboot-servicio-item</name>
15+
<description>Demo project for Spring Boot to update java versions</description>
16+
<properties>
17+
<java.version>11</java.version>
18+
<!--spring-cloud.version>2021.0.7<spring-cloud.version>-->
19+
<spring-cloud.version>Hoxton.SR12</spring-cloud.version>
20+
</properties>
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.springframework.boot</groupId>
24+
<artifactId>spring-boot-starter-web</artifactId>
25+
</dependency>
26+
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-devtools</artifactId>
30+
<scope>runtime</scope>
31+
<optional>true</optional>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter-test</artifactId>
36+
<scope>test</scope>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.springframework.cloud</groupId>
40+
<artifactId>spring-cloud-starter-openfeign</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.springframework.cloud</groupId>
44+
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
45+
</dependency>
46+
47+
</dependencies>
48+
49+
<build>
50+
<plugins>
51+
<plugin>
52+
<groupId>org.springframework.boot</groupId>
53+
<artifactId>spring-boot-maven-plugin</artifactId>
54+
</plugin>
55+
</plugins>
56+
</build>
57+
58+
<dependencyManagement>
59+
<dependencies>
60+
<dependency>
61+
<groupId>org.springframework.cloud</groupId>
62+
<artifactId>spring-cloud-dependencies</artifactId>
63+
<version>${spring-cloud.version}</version>
64+
<type>pom</type>
65+
<scope>import</scope>
66+
</dependency>
67+
</dependencies>
68+
</dependencyManagement>
69+
</project>

springboot.servicio-item/src/main/java/com/formacionbdi/springboot/app/item/config/AppConfig.java renamed to springboot-servicio-item/src/main/java/com/formacionbdi/springboot/app/item/AppConfig.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
package com.formacionbdi.springboot.app.item.config;
1+
package com.formacionbdi.springboot.app.item;
22

3+
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
34
import org.springframework.context.annotation.Bean;
45
import org.springframework.context.annotation.Configuration;
56
import org.springframework.web.client.RestTemplate;
@@ -8,7 +9,8 @@
89
public class AppConfig {
910

1011
@Bean("clienteRest")
12+
@LoadBalanced
1113
public RestTemplate registrarRestTemplate() {
1214
return new RestTemplate();
13-
}
15+
}
1416
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.formacionbdi.springboot.app.item;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.netflix.ribbon.RibbonClient;
6+
import org.springframework.cloud.netflix.ribbon.RibbonClient;
7+
import org.springframework.cloud.openfeign.EnableFeignClients;
8+
9+
@RibbonClient(name="servicio-productos")
10+
@EnableFeignClients
11+
@SpringBootApplication
12+
public class SpringbootServicioItemApplication {
13+
14+
public static void main(String[] args) {
15+
SpringApplication.run(SpringbootServicioItemApplication.class, args);
16+
}
17+
18+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.formacionbdi.springboot.app.item.clientes;
2+
3+
import java.util.List;
4+
5+
import org.springframework.cloud.openfeign.FeignClient;
6+
import org.springframework.web.bind.annotation.GetMapping;
7+
import org.springframework.web.bind.annotation.PathVariable;
8+
9+
import com.formacionbdi.springboot.app.item.models.Producto;
10+
11+
//@FeignClient(name = "servicio-productos", url="localhost:8001")
12+
@FeignClient(name = "servicio-productos") // Se quita dominio por ribbon configuration
13+
public interface ProductoClienteRest {
14+
15+
@GetMapping("/listar")
16+
public List<Producto> listar();
17+
18+
@GetMapping("/ver/{id}")
19+
public Producto detalle(@PathVariable Long id);
20+
21+
}

springboot.servicio-item/src/main/java/com/formacionbdi/springboot/app/item/controllers/ItemController.java renamed to springboot-servicio-item/src/main/java/com/formacionbdi/springboot/app/item/controllers/ItemController.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,29 @@
33
import java.util.List;
44

55
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.beans.factory.annotation.Qualifier;
67
import org.springframework.web.bind.annotation.GetMapping;
78
import org.springframework.web.bind.annotation.PathVariable;
89
import org.springframework.web.bind.annotation.RestController;
910

1011
import com.formacionbdi.springboot.app.item.models.Item;
11-
import com.formacionbdi.springboot.app.item.service.ItemService;
12+
import com.formacionbdi.springboot.app.item.models.service.ItemService;
1213

1314
@RestController
1415
public class ItemController {
1516

1617
@Autowired
18+
@Qualifier("serviceFeign")
19+
// @Qualifier("serviceRestTemplate")
1720
private ItemService itemService;
1821

1922
@GetMapping("/listar")
2023
public List<Item> listar(){
21-
return itemService.findAll();
24+
return itemService.findAll();
2225
}
23-
24-
@GetMapping("/ver/{id}/cantidad/{cantidad}")
26+
27+
@GetMapping("/ver/{id}/{cantidad}")
2528
public Item detalle(@PathVariable Long id, @PathVariable Integer cantidad){
2629
return itemService.findById(id, cantidad);
2730
}
28-
2931
}

0 commit comments

Comments
 (0)