Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 43 additions & 10 deletions 04.docker/01-step-by-step-changes/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,50 @@ Have a little bit of patience. Wait for 5-10 minutes if you do not see traces!
### Additional Changes For Spring Boot 3+

pom.xml
```xml
<!-- Enables tracing of REST API calls made using Feign-->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-micrometer</artifactId>
</dependency>
```
<!-- Enables tracing of REST API calls made using Feign-->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-micrometer</artifactId>
</dependency>
> Starting with **Spring Boot 4**, the recommended way to call external APIs is to use **RestClient**, as **RestTemplate** is planned for deprecation.

Reference Link: https://spring.io/blog/2025/09/30/the-state-of-http-clients-in-spring#the-future-of-http-clients-in-spring

To use **RestClient**, you need to add the **HTTP Client** starter in `start.spring.io`.

Follow these steps:

1. Open **start.spring.io**
2. Click **Add Dependencies**
3. Type `client` in the search box
4. Select **HTTP Client** from the list

```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-restclient</artifactId>
</dependency>
```

CurrencyConversionController.java
```
// Enable for Spring Boot 3.0.x
//@Configuration(proxyBeanMethods = false)
//class RestTemplateConfiguration {
//
// @Bean
// RestTemplate restTemplate(RestTemplateBuilder builder) {
// return builder.build();
// }
//}

@Configuration(proxyBeanMethods = false)
class RestTemplateConfiguration {
class RestClientConfiguration {

@Bean
RestTemplate restTemplate(RestTemplateBuilder builder) {
RestClient restClient(RestClient.Builder builder) {
return builder.build();
}
}
Expand All @@ -224,8 +253,12 @@ public class CurrencyConversionController {
@Autowired
private CurrencyExchangeProxy proxy;

@Autowired
private RestTemplate restTemplate;
// Uncomment for Spring Boot 3.0.x
// @Autowired
// private RestTemplate restTemplate;

@Autowired
private RestClient restClient;

```

Expand Down
20 changes: 8 additions & 12 deletions 04.docker/api-gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.0</version>
<version>4.0.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.in28minutes.microservices</groupId>
Expand All @@ -15,8 +15,8 @@
<description>Demo project for Spring Boot</description>

<properties>
<java.version>21</java.version>
<spring-cloud.version>2025.0.0</spring-cloud.version>
<java.version>25</java.version>
<spring-cloud.version>2025.1.0</spring-cloud.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -75,13 +75,17 @@
<artifactId>opentelemetry-exporter-zipkin</artifactId>
</dependency>


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down Expand Up @@ -116,12 +120,4 @@
</plugins>
</build>

<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>

</project>
30 changes: 14 additions & 16 deletions 04.docker/currency-conversion-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.0</version>
<version>4.0.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.in28minutes.microservices</groupId>
Expand All @@ -15,8 +15,8 @@
<description>Demo project for Spring Boot</description>

<properties>
<java.version>21</java.version>
<spring-cloud.version>2025.0.0</spring-cloud.version>
<java.version>25</java.version>
<spring-cloud.version>2025.1.0</spring-cloud.version>
</properties>

<dependencies>
Expand All @@ -26,7 +26,7 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.springframework.cloud</groupId>
Expand Down Expand Up @@ -93,11 +93,16 @@
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down Expand Up @@ -127,12 +132,5 @@
</plugins>
</build>

<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

// Enable for Spring Boot 3.0.x
//@Configuration(proxyBeanMethods = false)
//class RestTemplateConfiguration {
//
// @Bean
// RestTemplate restTemplate(RestTemplateBuilder builder) {
// return builder.build();
// }
//}

@Configuration(proxyBeanMethods = false)
class RestTemplateConfiguration {
class RestClientConfiguration {

@Bean
RestTemplate restTemplate(RestTemplateBuilder builder) {
RestClient restClient(RestClient.Builder builder) {
return builder.build();
}
}
Expand All @@ -28,8 +38,12 @@ public class CurrencyConversionController {
@Autowired
private CurrencyExchangeProxy proxy;

@Autowired
private RestTemplate restTemplate;
// Uncomment for Spring Boot 3.0.x
// @Autowired
// private RestTemplate restTemplate;

@Autowired
private RestClient restClient;

@GetMapping("/currency-conversion/from/{from}/to/{to}/quantity/{quantity}")
public CurrencyConversion calculateCurrencyConversion(
Expand All @@ -41,18 +55,23 @@ public CurrencyConversion calculateCurrencyConversion(
HashMap<String, String> uriVariables = new HashMap<>();
uriVariables.put("from",from);
uriVariables.put("to",to);

ResponseEntity<CurrencyConversion> responseEntity = restTemplate.getForEntity
("http://localhost:8000/currency-exchange/from/{from}/to/{to}",
CurrencyConversion.class, uriVariables);

CurrencyConversion currencyConversion = responseEntity.getBody();

return new CurrencyConversion(currencyConversion.getId(),
from, to, quantity,
currencyConversion.getConversionMultiple(),
quantity.multiply(currencyConversion.getConversionMultiple()),
currencyConversion.getEnvironment()+ " " + "rest template");

// ResponseEntity<CurrencyConversion> responseEntity = restTemplate.getForEntity
// ("http://localhost:8000/currency-exchange/from/{from}/to/{to}",
// CurrencyConversion.class, uriVariables);

CurrencyConversion currencyConversion = restClient.get()
.uri("http://localhost:8000/currency-exchange/from/{from}/to/{to}", uriVariables)
.retrieve()
.body(CurrencyConversion.class);

// CurrencyConversion currencyConversion = responseEntity.getBody();

return new CurrencyConversion(currencyConversion.getId(),
from, to, quantity,
currencyConversion.getConversionMultiple(),
quantity.multiply(currencyConversion.getConversionMultiple()),
currencyConversion.getEnvironment()+ " " + "rest client");

}

Expand Down
30 changes: 14 additions & 16 deletions 04.docker/currency-exchange-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.0</version>
<version>4.0.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.in28minutes.microservices</groupId>
Expand All @@ -15,8 +15,8 @@
<description>Demo project for Spring Boot</description>

<properties>
<java.version>21</java.version>
<spring-cloud.version>2025.0.0</spring-cloud.version>
<java.version>25</java.version>
<spring-cloud.version>2025.1.0</spring-cloud.version>
</properties>

<dependencies>
Expand All @@ -27,7 +27,7 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -102,11 +102,16 @@
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down Expand Up @@ -136,12 +141,5 @@
</plugins>
</build>

<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>

</project>
13 changes: 3 additions & 10 deletions 04.docker/naming-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.0</version>
<version>4.0.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.in28minutes.microservices</groupId>
Expand All @@ -15,8 +15,8 @@
<description>Demo project for Spring Boot</description>

<properties>
<java.version>21</java.version>
<spring-cloud.version>2025.0.0</spring-cloud.version>
<java.version>25</java.version>
<spring-cloud.version>2025.1.0</spring-cloud.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -75,12 +75,5 @@
</plugins>
</build>

<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>

</project>