File tree Expand file tree Collapse file tree 4 files changed +20
-32
lines changed
src/main/java/guides/hazelcast/springboot Expand file tree Collapse file tree 4 files changed +20
-32
lines changed Original file line number Diff line number Diff line change 1111 <parent >
1212 <groupId >org.springframework.boot</groupId >
1313 <artifactId >spring-boot-starter-parent</artifactId >
14- <version >2.4.1</version >
15- <relativePath />
14+ <version >3.4.1</version >
1615 </parent >
1716
1817 <properties >
19- <java .version>1.8 </java .version>
20- <hazelcast .version>5.3.2 </hazelcast .version>
18+ <java .version>17 </java .version>
19+ <hazelcast .version>5.5.0 </hazelcast .version>
2120 </properties >
2221
2322 <build >
3635 <plugins >
3736 <plugin >
3837 <artifactId >maven-failsafe-plugin</artifactId >
39- <version >2.22 .2</version >
38+ <version >3.5 .2</version >
4039 <executions >
4140 <execution >
4241 <goals >
7776 <dependency >
7877 <groupId >net.minidev</groupId >
7978 <artifactId >json-smart</artifactId >
80- <version >2.3 </version >
79+ <version >2.5.1 </version >
8180 <scope >test</scope >
8281 </dependency >
8382 </dependencies >
Original file line number Diff line number Diff line change 11package guides .hazelcast .springboot ;
22
3- import com .hazelcast .core . HazelcastInstance ;
3+ import com .hazelcast .map . IMap ;
44import org .springframework .beans .factory .annotation .Autowired ;
5+ import org .springframework .beans .factory .annotation .Qualifier ;
56import org .springframework .web .bind .annotation .GetMapping ;
67import org .springframework .web .bind .annotation .PostMapping ;
78import org .springframework .web .bind .annotation .RequestParam ;
89import org .springframework .web .bind .annotation .RestController ;
910
10- import java .util .concurrent .ConcurrentMap ;
11-
1211@ RestController
1312public class CommandController {
14- @ Autowired
15- private HazelcastInstance hazelcastInstance ;
16-
17- private ConcurrentMap <String ,String > retrieveMap () {
18- return hazelcastInstance .getMap ("map" );
19- }
13+ @ Autowired @ Qualifier ("map" )
14+ private IMap <String , String > map ;
2015
2116 @ PostMapping ("/put" )
2217 public CommandResponse put (@ RequestParam (value = "key" ) String key , @ RequestParam (value = "value" ) String value ) {
23- retrieveMap () .put (key , value );
18+ map .put (key , value );
2419 return new CommandResponse (value );
2520 }
2621
2722 @ GetMapping ("/get" )
2823 public CommandResponse get (@ RequestParam (value = "key" ) String key ) {
29- String value = retrieveMap () .get (key );
24+ String value = map .get (key );
3025 return new CommandResponse (value );
3126 }
3227}
Original file line number Diff line number Diff line change 11package guides .hazelcast .springboot ;
22
3- public class CommandResponse {
4-
5- private String value ;
6-
7- public CommandResponse (String value ) {
8- this .value = value ;
9- }
10-
11- public String getValue () {
12- return value ;
13- }
14-
15- public void setValue (String value ) {
16- this .value = value ;
17- }
3+ public record CommandResponse (String value ) {
184}
Original file line number Diff line number Diff line change 11package guides .hazelcast .springboot ;
22
3+ import com .hazelcast .core .HazelcastInstance ;
4+ import com .hazelcast .map .IMap ;
35import org .springframework .boot .SpringApplication ;
46import org .springframework .boot .autoconfigure .SpringBootApplication ;
7+ import org .springframework .context .annotation .Bean ;
58import org .springframework .web .bind .annotation .RestController ;
69
710@ SpringBootApplication
@@ -10,4 +13,9 @@ public class HazelcastApplication {
1013 public static void main (String [] args ) {
1114 SpringApplication .run (HazelcastApplication .class , args );
1215 }
16+
17+ @ Bean
18+ public IMap <String , String > map (HazelcastInstance instance ) {
19+ return instance .getMap ("map" );
20+ }
1321}
You can’t perform that action at this time.
0 commit comments