Skip to content

Commit 918b9cc

Browse files
authored
Use Boot 4 everywhere. WAN replication fixes in Spring example (#762)
1 parent 2246be3 commit 918b9cc

14 files changed

Lines changed: 84 additions & 35 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<maven.assembly.plugin.version>3.0.0</maven.assembly.plugin.version>
4646

4747
<lombok.version>1.18.40</lombok.version>
48-
<spring.boot.version>3.5.4</spring.boot.version>
48+
<spring.boot.version>4.0.0</spring.boot.version>
4949
</properties>
5050

5151
<modules>

spring/resilient-sessions/docker/conf-lon/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ hazelcast:
3030
- type: HASH
3131
attributes:
3232
- "principalName"
33+
products:
34+
wan-replication-ref:
35+
replicate-to-nyc:
36+
merge-policy-class-name: PutIfAbsentMergePolicy
37+
backup-count: 1

spring/resilient-sessions/docker/conf-newyork/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ hazelcast:
3030
- type: HASH
3131
attributes:
3232
- "principalName"
33+
products:
34+
wan-replication-ref:
35+
eplicate-to-lon:
36+
merge-policy-class-name: PutIfAbsentMergePolicy
37+
backup-count: 1

spring/spring-boot-caching-hazelcast-cache-manager/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,21 @@
6666
<artifactId>hazelcast-spring</artifactId>
6767
<version>${hazelcast.version}</version>
6868
</dependency>
69+
<dependency>
70+
<groupId>org.springframework.boot</groupId>
71+
<artifactId>spring-boot-hazelcast</artifactId>
72+
</dependency>
6973

7074
<dependency>
7175
<groupId>org.springframework.boot</groupId>
7276
<artifactId>spring-boot-starter-test</artifactId>
7377
<scope>test</scope>
78+
<exclusions>
79+
<exclusion>
80+
<groupId>org.springframework.boot</groupId>
81+
<artifactId>spring-boot-starter-logging</artifactId>
82+
</exclusion>
83+
</exclusions>
7484
</dependency>
7585
</dependencies>
7686
</project>

spring/spring-boot-caching-hazelcast-cache-manager/src/test/java/com/hazelcast/springboot/caching/ApplicationTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import org.springframework.beans.factory.annotation.Autowired;
66
import org.springframework.boot.test.context.SpringBootTest;
77
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
8-
import org.springframework.boot.test.web.client.TestRestTemplate;
98
import org.springframework.boot.test.web.server.LocalServerPort;
9+
import org.springframework.test.web.servlet.client.RestTestClient;
1010

1111
import static org.assertj.core.api.Assertions.assertThat;
1212

@@ -16,21 +16,22 @@ class ApplicationTest {
1616
@LocalServerPort
1717
private int port;
1818

19-
@Autowired
20-
private TestRestTemplate restTemplate;
21-
2219
@Autowired
2320
private HazelcastInstance hazelcastInstance;
2421

2522
@Test
2623
void useCachedValue() {
2724
// given
25+
RestTestClient restTestClient = RestTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
2826
String isbn = "12345";
2927
String cachedValue = "cached-value";
3028
hazelcastInstance.getMap("books").put(isbn, cachedValue);
3129

3230
// when
33-
String response = restTemplate.getForObject(String.format("http://localhost:%s/books/%s", port, isbn), String.class);
31+
String response = restTestClient.get().uri(String.format("http://localhost:%s/books/%s", port, isbn))
32+
.exchange()
33+
.returnResult(String.class)
34+
.getResponseBody();
3435

3536
// then
3637
assertThat(response).isEqualTo(cachedValue);

spring/spring-boot-caching-jcache/pom.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,20 @@
6363
<groupId>org.springframework.boot</groupId>
6464
<artifactId>spring-boot-starter-log4j2</artifactId>
6565
</dependency>
66-
<dependency>
67-
<groupId>org.apache.logging.log4j</groupId>
68-
<artifactId>log4j-spring-boot</artifactId>
69-
</dependency>
7066

7167
<!-- tag::hazelcast[] -->
7268
<dependency>
7369
<groupId>com.hazelcast</groupId>
7470
<artifactId>hazelcast</artifactId>
75-
<version>5.5.0</version>
71+
<version>5.6.0</version>
7672
</dependency>
7773
<!-- end::hazelcast[] -->
7874

75+
<dependency>
76+
<groupId>org.springframework.boot</groupId>
77+
<artifactId>spring-boot-hazelcast</artifactId>
78+
</dependency>
79+
7980
<dependency>
8081
<groupId>javax.cache</groupId>
8182
<artifactId>cache-api</artifactId>
@@ -91,6 +92,10 @@
9192
<groupId>org.junit.vintage</groupId>
9293
<artifactId>junit-vintage-engine</artifactId>
9394
</exclusion>
95+
<exclusion>
96+
<groupId>org.springframework.boot</groupId>
97+
<artifactId>spring-boot-starter-logging</artifactId>
98+
</exclusion>
9499
</exclusions>
95100
</dependency>
96101
</dependencies>

spring/spring-boot-caching-jcache/src/test/java/com/hazelcast/springboot/caching/ApplicationClientServerTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import org.springframework.beans.factory.annotation.Autowired;
88
import org.springframework.boot.test.context.SpringBootTest;
99
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
10-
import org.springframework.boot.test.web.client.TestRestTemplate;
1110
import org.springframework.boot.test.web.server.LocalServerPort;
11+
import org.springframework.test.web.servlet.client.RestTestClient;
1212

1313
import static org.assertj.core.api.Assertions.assertThat;
1414

@@ -18,9 +18,6 @@ class ApplicationClientServerTest {
1818
@LocalServerPort
1919
private int port;
2020

21-
@Autowired
22-
private TestRestTemplate restTemplate;
23-
2421
@Autowired
2522
private HazelcastInstance hazelcastInstance;
2623

@@ -31,13 +28,17 @@ static void setUp() {
3128

3229
@Test
3330
void useCachedValue() {
31+
RestTestClient restTestClient = RestTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
3432
// given
3533
String isbn = "12345";
3634
String cachedValue = "cached-value";
3735
hazelcastInstance.getCacheManager().getCache("books").put(isbn, cachedValue);
3836

3937
// when
40-
String response = restTemplate.getForObject(String.format("http://localhost:%s/books/%s", port, isbn), String.class);
38+
String response = restTestClient.get().uri(String.format("http://localhost:%s/books/%s", port, isbn))
39+
.exchange()
40+
.returnResult(String.class)
41+
.getResponseBody();
4142

4243
// then
4344
assertThat(response).isEqualTo(cachedValue);

spring/spring-boot-caching-jcache/src/test/java/com/hazelcast/springboot/caching/ApplicationEmbeddedTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import org.springframework.beans.factory.annotation.Autowired;
66
import org.springframework.boot.test.context.SpringBootTest;
77
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
8-
import org.springframework.boot.test.web.client.TestRestTemplate;
8+
import org.springframework.test.web.servlet.client.RestTestClient;
99
import org.springframework.boot.test.web.server.LocalServerPort;
1010
import org.springframework.test.context.ActiveProfiles;
1111

@@ -18,21 +18,23 @@ class ApplicationEmbeddedTest {
1818
@LocalServerPort
1919
private int port;
2020

21-
@Autowired
22-
private TestRestTemplate restTemplate;
23-
2421
@Autowired
2522
private HazelcastInstance hazelcastInstance;
2623

2724
@Test
2825
void useCachedValue() {
26+
RestTestClient restTestClient = RestTestClient.bindToServer().baseUrl("http://localhost:" + port).build();
27+
2928
// given
3029
String isbn = "12345";
3130
String cachedValue = "cached-value";
3231
hazelcastInstance.getCacheManager().getCache("books").put(isbn, cachedValue);
3332

3433
// when
35-
String response = restTemplate.getForObject(String.format("http://localhost:%s/books/%s", port, isbn), String.class);
34+
String response = restTestClient.get().uri(String.format("http://localhost:%s/books/%s", port, isbn))
35+
.exchange()
36+
.returnResult(String.class)
37+
.getResponseBody();
3638

3739
// then
3840
assertThat(response).isEqualTo(cachedValue);

spring/spring-boot-embedded/pom.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,28 @@
5454
<artifactId>spring-boot-starter-log4j2</artifactId>
5555
</dependency>
5656
<dependency>
57-
<groupId>org.apache.logging.log4j</groupId>
58-
<artifactId>log4j-spring-boot</artifactId>
57+
<groupId>org.springframework.boot</groupId>
58+
<artifactId>spring-boot-hazelcast</artifactId>
5959
</dependency>
6060

6161
<!-- tag::hazelcast-dep[] -->
6262
<dependency>
6363
<groupId>com.hazelcast</groupId>
6464
<artifactId>hazelcast-spring</artifactId>
65-
<version>5.5.0</version>
65+
<version>5.6.0</version>
6666
</dependency>
6767
<!-- end::hazelcast-dep[] -->
6868

6969
<dependency>
7070
<groupId>org.springframework.boot</groupId>
7171
<artifactId>spring-boot-starter-test</artifactId>
7272
<scope>test</scope>
73+
<exclusions>
74+
<exclusion>
75+
<groupId>org.springframework.boot</groupId>
76+
<artifactId>spring-boot-starter-logging</artifactId>
77+
</exclusion>
78+
</exclusions>
7379
</dependency>
7480
<dependency>
7581
<groupId>org.springframework.boot</groupId>

spring/spring-boot-embedded/src/main/java/guides/hazelcast/springboot/HazelcastApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.springframework.boot.autoconfigure.SpringBootApplication;
88
import org.springframework.context.annotation.Bean;
99

10-
@SpringBootApplication
10+
@SpringBootApplication(excludeName = "com.hazelcast.spring.HazelcastObjectExtractionConfiguration")
1111
public class HazelcastApplication {
1212

1313
public static void main(String[] args) {

0 commit comments

Comments
 (0)