Skip to content

Commit db941da

Browse files
author
Ivan Franchin
committed
Project upgrade
- Upgrade to spring-boot 3.2.5; - Upgrade to springdoc-openapi 2.5.0; - Upgrade to apache-maven 3.9.5; - Upgrade to jib-maven-plugin 3.4.2; - Upgrade to amazoncorretto-jdk 17.0.10 - Upgrade to elasticsearch docker image 8.10.4; - Add in create-index.sh, a request to Elasticsearch to Fix High Disk Watermark issue; - Remove obsolete version field in docker-compose.yml; - Update README.
1 parent a8fd823 commit db941da

File tree

9 files changed

+47
-27
lines changed

9 files changed

+47
-27
lines changed

.mvn/wrapper/maven-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
22
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

README.adoc

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
= springboot-elasticsearch-thymeleaf
22

3-
The goal of this project is to implement an application called `product-app`. It consists of two https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/[`Spring Boot`] services: `product-api` (backend) and `product-ui` (frontend). The data will be stored in https://www.elastic.co/products/elasticsearch[`Elasticsearch`].
3+
The goal of this project is to implement an application called `product-app`. It consists of two https://spring.io/projects/spring-boot[`Spring Boot`] services: `product-api` (backend) and `product-ui` (frontend). The data will be stored in https://www.elastic.co/products/elasticsearch[`Elasticsearch`].
44

55
== Proof-of-Concepts & Articles
66

@@ -14,7 +14,7 @@ image::documentation/project-diagram.jpeg[]
1414

1515
* **product-api**
1616
+
17-
`Spring Boot` Web Java application that exposes a REST API to manages products. The information about products is stored in `Elasticsearch`. `product-api` uses https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/[`Spring Data Elasticsearch`] to persist/query/delete data in https://www.elastic.co/products/elasticsearch[`Elasticsearch`]
17+
`Spring Boot` Web Java application that exposes a REST API to manages products. The information about products is stored in `Elasticsearch`. `product-api` uses https://docs.spring.io/spring-data/elasticsearch/reference/[`Spring Data Elasticsearch`] to persist/query/delete data in https://www.elastic.co/products/elasticsearch[`Elasticsearch`].
1818

1919
* **product-ui**
2020
+
@@ -27,14 +27,14 @@ image::documentation/project-diagram.jpeg[]
2727

2828
== Start Environment
2929

30-
* Open a terminal and navigate to `springboot-elasticsearch-thymeleaf` root folder run
30+
* Open a terminal and navigate to `springboot-elasticsearch-thymeleaf` root folder run:
3131
+
3232
[source]
3333
----
3434
docker compose up -d
3535
----
3636

37-
* Wait for `Elasticsearch` Docker container to be up and running. To check it, run
37+
* Wait for `Elasticsearch` Docker container to be up and running. To check it, run:
3838
+
3939
[source]
4040
----
@@ -45,23 +45,23 @@ docker compose ps
4545

4646
NOTE: In the following steps, we will create an index, an alias and do a reindex using pre-defined scripts. In case you prefer to do it step-by-step calling `Elasticsearch` API, refer to link:create-index-alias-reindex.adoc[Creating indexes, alias and reindexing using Elasticsearch API].
4747

48-
* In a terminal, make sure you are in `springboot-elasticsearch-thymeleaf` root folder
48+
* In a terminal, make sure you are in `springboot-elasticsearch-thymeleaf` root folder;
4949

50-
* Run the following script to create the index `ecommerce.products.v1` with the alias `ecommerce.products` (you can use the default values by just pressing `Enter` on every user input)
50+
* Run the following script to create the index `ecommerce.products.v1` with the alias `ecommerce.products` (you can use the default values by just pressing `Enter` on every user input):
5151
+
5252
[source]
5353
----
5454
./create-index.sh
5555
----
5656

57-
* If you want to insert some products, run
57+
* If you want to insert some products, run:
5858
+
5959
[source]
6060
----
6161
./insert-products.sh
6262
----
6363

64-
* If you want to fix the `reference` property mapping error (explained below), run
64+
* If you want to fix the `reference` property mapping error (explained below), run:
6565
+
6666
[source]
6767
----
@@ -95,8 +95,8 @@ Below are the steps to start and run the applications using `Maven`. We will nee
9595
== Running applications as Docker containers
9696

9797
* Build Docker Images
98-
** In a terminal, make sure you are in `springboot-elasticsearch-thymeleaf` root folder
99-
** Run the following script
98+
** In a terminal, make sure you are in `springboot-elasticsearch-thymeleaf` root folder;
99+
** Run the following script:
100100
+
101101
[source]
102102
----
@@ -126,8 +126,8 @@ Below are the steps to start and run the applications using `Maven`. We will nee
126126
|===
127127

128128
* Run Docker containers
129-
** In a terminal, make sure you are in `springboot-elasticsearch-thymeleaf` root folder
130-
** Run the following script
129+
** In a terminal, make sure you are in `springboot-elasticsearch-thymeleaf` root folder;
130+
** Run the following script:
131131
+
132132
[source]
133133
----
@@ -148,21 +148,21 @@ Below are the steps to start and run the applications using `Maven`. We will nee
148148

149149
== Demo
150150

151-
* Below is a simple demo that shows a user interacting with `product-ui`
151+
* Below is a simple demo that shows a user interacting with `product-ui`:
152152
+
153153
image::documentation/demo-user-interaction.gif[]
154154

155155
== Shutdown
156156

157-
* To stop applications
158-
** If they were started with `Maven`, go to `product-api` and `product-ui` terminals and press `Ctrl+C`
159-
** If they were started as Docker containers, go to a terminal and, inside `springboot-elasticsearch-thymeleaf` root folder, run the script below
157+
* To stop applications:
158+
** If they were started with `Maven`, go to `product-api` and `product-ui` terminals and press `Ctrl+C`;
159+
** If they were started as Docker containers, go to a terminal and, inside `springboot-elasticsearch-thymeleaf` root folder, run the script below:
160160
+
161161
[source]
162162
----
163163
./stop-apps.sh
164164
----
165-
* To stop and remove docker compose containers, network and volumes, go to a terminal and, inside `springboot-elasticsearch-thymeleaf` root folder, run the following command
165+
* To stop and remove docker compose containers, network and volumes, go to a terminal and, inside `springboot-elasticsearch-thymeleaf` root folder, run the following command:
166166
+
167167
[source]
168168
----
@@ -171,7 +171,7 @@ docker compose down -v
171171

172172
== Cleanup
173173

174-
To remove the Docker images created by this project, go to a terminal and, inside `springboot-elasticsearch-thymeleaf` root folder, run the script below
174+
To remove the Docker images created by this project, go to a terminal and, inside `springboot-elasticsearch-thymeleaf` root folder, run the script below:
175175
[source]
176176
----
177177
./remove-docker-images.sh

create-index.sh

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
#!/usr/bin/env bash
22

3+
echo "-----------------------"
4+
echo "Fix High Disk Watermark"
5+
echo "-----------------------"
6+
# Reference: https://www.elastic.co/guide/en/elasticsearch/reference/current/fix-watermark-errors.html
7+
8+
curl -X PUT localhost:9200/_cluster/settings \
9+
-H "Content-Type: application/json" \
10+
-d '{ "persistent": { "cluster.routing.allocation.disk.watermark.low": "90%", "cluster.routing.allocation.disk.watermark.low.max_headroom": "100GB", "cluster.routing.allocation.disk.watermark.high": "95%", "cluster.routing.allocation.disk.watermark.high.max_headroom": "20GB", "cluster.routing.allocation.disk.watermark.flood_stage": "97%", "cluster.routing.allocation.disk.watermark.flood_stage.max_headroom": "5GB", "cluster.routing.allocation.disk.watermark.flood_stage.frozen": "97%", "cluster.routing.allocation.disk.watermark.flood_stage.frozen.max_headroom": "5GB" } }'
11+
12+
echo
13+
echo "-----------------"
14+
echo "Configuring index"
15+
echo "-----------------"
16+
317
read -p "Type index alias (ecommerce.products): " index_alias
418
index_alias=${index_alias:-ecommerce.products}
519

docker-compose.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
version: "3.8"
2-
31
services:
42

53
elasticsearch:
6-
image: docker.elastic.co/elasticsearch/elasticsearch:8.7.1
4+
image: docker.elastic.co/elasticsearch/elasticsearch:8.10.4
75
container_name: elasticsearch
86
restart: unless-stopped
97
ports:

insert-products.sh

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/bin/env bash
22

3+
echo "------------------"
4+
echo "Inserting products"
5+
echo "------------------"
6+
37
read -p "Type index name or alias (ecommerce.products): " index_name_alias
48
index_name_alias=${index_name_alias:-ecommerce.products}
59

pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.1.4</version>
8+
<version>3.2.5</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111

@@ -18,8 +18,8 @@
1818

1919
<properties>
2020
<java.version>17</java.version>
21-
<jib-maven-plugin.version>3.4.0</jib-maven-plugin.version>
22-
<jdk-image.version>17.0.8</jdk-image.version>
21+
<jib-maven-plugin.version>3.4.2</jib-maven-plugin.version>
22+
<jdk-image.version>17.0.10</jdk-image.version>
2323
<docker-image.prefix>ivanfranchin</docker-image.prefix>
2424
</properties>
2525

product-api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<properties>
1717
<org.mapstruct.version>1.5.5.Final</org.mapstruct.version>
18-
<springdoc-openapi.version>2.2.0</springdoc-openapi.version>
18+
<springdoc-openapi.version>2.5.0</springdoc-openapi.version>
1919
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
2020
</properties>
2121

product-ui/src/main/java/com/ivanfranchin/productui/client/ProductApiClientConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public ProductApiClient productApiClient() {
1919
.baseUrl(productApiUrl)
2020
.build();
2121
HttpServiceProxyFactory factory = HttpServiceProxyFactory
22-
.builder(WebClientAdapter.forClient(webClient))
22+
.builderFor(WebClientAdapter.create(webClient))
2323
.build();
2424
return factory.createClient(ProductApiClient.class);
2525
}

reindex.sh

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/bin/env bash
22

3+
echo "-------------------"
4+
echo "Applying reindexing"
5+
echo "-------------------"
6+
37
read -p "Type the index alias (ecommerce.products): " index_alias
48
index_alias=${index_alias:-ecommerce.products}
59

0 commit comments

Comments
 (0)