Skip to content

Commit d5d0c8f

Browse files
authored
Merge pull request #14 from Nasruddin/revamp
Upgrade to spring boot 3
2 parents 423c637 + 49b8267 commit d5d0c8f

File tree

19 files changed

+120
-78
lines changed

19 files changed

+120
-78
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/.idea/
2+
/Status

.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker/docker-compose.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: '2.1'
33
services:
44
course:
55
build: ../microservices/course-service
6-
image: javatab/course_service:v1
6+
image: javatab/course_service:v2
77
mem_limit: 512m
88
environment:
99
- SPRING_PROFILES_ACTIVE=docker
@@ -15,7 +15,7 @@ services:
1515

1616
search:
1717
build: ../microservices/search-service
18-
image: javatab/search_service:v1
18+
image: javatab/search_service:v2
1919
mem_limit: 512m
2020
environment:
2121
- SPRING_PROFILES_ACTIVE=docker
@@ -27,7 +27,7 @@ services:
2727

2828
student:
2929
build: ../microservices/student-service
30-
image: javatab/student_service:v1
30+
image: javatab/student_service:v2
3131
mem_limit: 512m
3232
environment:
3333
- SPRING_PROFILES_ACTIVE=docker
@@ -39,7 +39,7 @@ services:
3939

4040
vote:
4141
build: ../microservices/vote-service
42-
image: javatab/vote_service:v1
42+
image: javatab/vote_service:v2
4343
mem_limit: 512m
4444
environment:
4545
- SPRING_PROFILES_ACTIVE=docker
@@ -51,7 +51,7 @@ services:
5151

5252
course-composite:
5353
build: ../microservices/course-composite-service
54-
image: javatab/course_composite_service:v1
54+
image: javatab/course_composite_service:v2
5555
mem_limit: 512m
5656
environment:
5757
- SPRING_PROFILES_ACTIVE=docker
@@ -71,7 +71,7 @@ services:
7171
retries: 60
7272

7373
postgres:
74-
image: postgres:alpine3.15
74+
image: postgres:13.7-alpine3.16
7575
mem_limit: 512m
7676
ports:
7777
- "5432:5432"
@@ -119,6 +119,7 @@ services:
119119

120120
eureka:
121121
build: ../spring-cloud/eureka-server
122+
image: javatab/eureka:v2
122123
mem_limit: 512m
123124
environment:
124125
- SPRING_PROFILES_ACTIVE=docker
@@ -127,6 +128,7 @@ services:
127128

128129
gateway:
129130
build: ../spring-cloud/gateway
131+
image: javatab/gateway:v2
130132
mem_limit: 512m
131133
ports:
132134
- "8443:8443"
@@ -144,6 +146,7 @@ services:
144146
- CONFIG_SERVER_USR=${CONFIG_SERVER_USR}
145147
- CONFIG_SERVER_PWD=${CONFIG_SERVER_PWD}
146148
build: ../spring-cloud/authorization-server
149+
image: javatab/auth-server:v2
147150
mem_limit: 512m
148151
#healthcheck:
149152
# test: "curl --fail --silent http://localhost:9999/actuator/health | grep UP || exit 1"
@@ -153,6 +156,7 @@ services:
153156

154157
config-server:
155158
build: ../spring-cloud/config-server
159+
image: javatab/config-server:v2
156160
mem_limit: 512m
157161
environment:
158162
- SPRING_PROFILES_ACTIVE=docker,native

microservices/course-composite-service/pom.xml

Lines changed: 1 addition & 1 deletion
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>2.6.6</version>
8+
<version>3.0.5</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>io.javatab.microservices.composite.course</groupId>

microservices/course-composite-service/src/main/java/io/javatab/microservices/composite/course/configuration/OpenApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
scopes = {
2323
@OAuthScope(name = "course:read", description =
2424
"read scope"),
25-
@OAuthScope(name = "write:write", description =
25+
@OAuthScope(name = "course:write", description =
2626
"write scope")
2727
}
2828
)))

microservices/course-composite-service/src/main/java/io/javatab/microservices/composite/course/service/CourseCompositeIntegration.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.javatab.microservices.util.http.HttpErrorInfo;
1313
import org.slf4j.Logger;
1414
import org.slf4j.LoggerFactory;
15+
import org.springframework.http.HttpStatusCode;
1516
import org.springframework.stereotype.Component;
1617
import org.springframework.web.reactive.function.client.WebClient;
1718
import org.springframework.web.reactive.function.client.WebClientResponseException;
@@ -20,6 +21,8 @@
2021
import java.io.IOException;
2122

2223
import static java.util.logging.Level.FINE;
24+
import static org.springframework.http.HttpStatus.NOT_FOUND;
25+
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
2326

2427
@Component
2528
public class CourseCompositeIntegration implements CourseService, StudentService, VoteService {
@@ -50,26 +53,20 @@ private String getErrorMessage(WebClientResponseException ex) {
5053

5154
private Throwable handleException(Throwable ex) {
5255

53-
if (!(ex instanceof WebClientResponseException)) {
56+
if (!(ex instanceof WebClientResponseException webClientResponseException)) {
5457
LOG.warn("Got a unexpected error: {}, will rethrow it", ex.toString());
5558
return ex;
5659
}
5760

58-
WebClientResponseException wcre = (WebClientResponseException)ex;
59-
60-
switch (wcre.getStatusCode()) {
61-
62-
case NOT_FOUND:
63-
return new NotFoundException(getErrorMessage(wcre));
64-
65-
case UNPROCESSABLE_ENTITY :
66-
return new InvalidInputException(getErrorMessage(wcre));
67-
68-
default:
69-
LOG.warn("Got an unexpected HTTP error: {}, will rethrow it", wcre.getStatusCode());
70-
LOG.warn("Error body: {}", wcre.getResponseBodyAsString());
71-
return ex;
61+
HttpStatusCode statusCode = webClientResponseException.getStatusCode();
62+
if (NOT_FOUND.equals(statusCode)) {
63+
return new NotFoundException(getErrorMessage(webClientResponseException));
64+
} else if (UNPROCESSABLE_ENTITY.equals(statusCode)) {
65+
return new InvalidInputException(getErrorMessage(webClientResponseException));
7266
}
67+
LOG.warn("Got an unexpected HTTP error: {}, will rethrow it", webClientResponseException.getStatusCode());
68+
LOG.warn("Error body: {}", webClientResponseException.getResponseBodyAsString());
69+
return ex;
7370
}
7471
@Override
7572
public Mono<Course> getCourse(int courseId) {

microservices/course-service/pom.xml

Lines changed: 1 addition & 1 deletion
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>2.6.6</version>
8+
<version>3.0.5</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>io.javatab.microservices.core.course</groupId>

microservices/course-service/src/test/java/io/javatab/microservices/core/course/PersistenceTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
import org.junit.jupiter.api.BeforeEach;
77
import org.junit.jupiter.api.Test;
88
import org.springframework.beans.factory.annotation.Autowired;
9-
import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration;
109
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
1110

1211
import static org.junit.jupiter.api.Assertions.assertEquals;
1312

1413
@DataMongoTest(
15-
excludeAutoConfiguration = EmbeddedMongoAutoConfiguration.class,
1614
properties = {"spring.cloud.config.enabled=false"}
1715
)
1816
public class PersistenceTests extends MongoDbTestBase {

microservices/search-service/pom.xml

Lines changed: 1 addition & 1 deletion
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>2.6.6</version>
8+
<version>3.0.5</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>io.javatab.microservices.core.search</groupId>

microservices/search-service/src/main/java/io/javatab/microservices/core/search/persistence/ElasticRepository.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
package io.javatab.microservices.core.search.persistence;
22

33

4+
import co.elastic.clients.elasticsearch.core.DeleteResponse;
5+
import co.elastic.clients.elasticsearch.core.IndexResponse;
46
import com.fasterxml.jackson.databind.ObjectMapper;
5-
import io.javatab.microservices.api.core.course.Course;
6-
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
7-
import org.elasticsearch.action.delete.DeleteResponse;
8-
import org.elasticsearch.action.index.IndexResponse;
9-
import org.elasticsearch.client.RequestOptions;
10-
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
7+
import org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient;
118
import org.springframework.stereotype.Repository;
129
import reactor.core.publisher.Mono;
1310

@@ -30,7 +27,8 @@ public Mono<IndexResponse> createCourse(SearchEntity course) {
3027
String id = UUID.randomUUID().toString();
3128
Map documentMapper = objectMapper.convertValue(course,
3229
Map.class);
33-
return client.index(indexRequest -> indexRequest.index(COURSE_INDEX).id(id).source(documentMapper));
30+
// return client.index(indexRequest -> indexRequest.index(COURSE_INDEX).id(id).source(documentMapper));
31+
return client.index(indexRequest -> indexRequest.index(COURSE_INDEX).id(id).document(documentMapper));
3432
}
3533

3634
public Mono<DeleteResponse> deleteCourse() {

0 commit comments

Comments
 (0)