diff --git a/boot-mongodb-elasticsearch/docker/docker-compose-cluster.yml b/boot-mongodb-elasticsearch/docker/docker-compose-cluster.yml index cb9b828cc..310e1f783 100644 --- a/boot-mongodb-elasticsearch/docker/docker-compose-cluster.yml +++ b/boot-mongodb-elasticsearch/docker/docker-compose-cluster.yml @@ -4,7 +4,7 @@ services: mongo1: container_name: mongo1 hostname: mongo1 - image: mongo:6.0.13 + image: mongo:7.0.5 extra_hosts: - "host.docker.internal:host-gateway" - "docker.for.win.host.internal:host-gateway" @@ -20,7 +20,7 @@ services: mongo2: container_name: mongo2 hostname: mongo2 - image: mongo:6.0.13 + image: mongo:7.0.5 extra_hosts: - "host.docker.internal:host-gateway" - "docker.for.win.host.internal:host-gateway" @@ -33,7 +33,7 @@ services: mongo3: container_name: mongo3 hostname: mongo3 - image: mongo:6.0.13 + image: mongo:7.0.5 extra_hosts: - "host.docker.internal:host-gateway" - "docker.for.win.host.internal:host-gateway" diff --git a/boot-mongodb-elasticsearch/docker/docker-compose.yml b/boot-mongodb-elasticsearch/docker/docker-compose.yml index 6fb645ba1..d0cd78b2d 100644 --- a/boot-mongodb-elasticsearch/docker/docker-compose.yml +++ b/boot-mongodb-elasticsearch/docker/docker-compose.yml @@ -3,13 +3,14 @@ version: "3.9" services: mongodb: hostname: mongodb - image: mongo:6.0.13 + image: mongo:7.0.5 volumes: - mongodb:/data/db ports: - "27017:27017" healthcheck: - test: test $$(echo "rs.initiate().ok || rs.status().ok" | mongo --quiet) -eq 1 + test: | + mongosh --eval "try { rs.status().ok } catch (e) { rs.initiate({ _id: 'rs0', members: [{ _id: 0, host: 'localhost:27017' }] }).ok }" interval: 10s start_period: 30s command: ["/usr/bin/mongod", "--replSet", "rs0", "--bind_ip_all"] diff --git a/boot-mongodb-elasticsearch/pom.xml b/boot-mongodb-elasticsearch/pom.xml index e926f7536..2558fbecc 100644 --- a/boot-mongodb-elasticsearch/pom.xml +++ b/boot-mongodb-elasticsearch/pom.xml @@ -229,7 +229,7 @@ - 1.17.0 + 1.19.2 diff --git a/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/controller/RestaurantController.java b/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/controller/RestaurantController.java index 062277379..e4d1ac0ac 100644 --- a/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/controller/RestaurantController.java +++ b/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/controller/RestaurantController.java @@ -32,8 +32,8 @@ public class RestaurantController { @GetMapping public Mono>> findAllRestaurants( - @Valid @RequestParam(defaultValue = "10") @Size(max = 999) Integer limit, - @RequestParam(defaultValue = "0") Integer offset) { + @Valid @RequestParam(defaultValue = "10") @Size(max = 999) int limit, + @RequestParam(defaultValue = "0") int offset) { return restaurantService.findAllRestaurants(offset, limit).map(ResponseEntity::ok); } diff --git a/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/service/RestaurantService.java b/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/service/RestaurantService.java index 60e94c384..d854b33a5 100644 --- a/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/service/RestaurantService.java +++ b/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/service/RestaurantService.java @@ -203,7 +203,7 @@ private List getResumeToken() { return this.changeStreamResumeRepository.findAll().toStream().toList(); } - public Mono> findAllRestaurants(Integer offset, Integer limit) { + public Mono> findAllRestaurants(int offset, int limit) { Sort sort = Sort.by(Sort.Direction.DESC, "restaurant_id"); Pageable pageable = PageRequest.of(offset, limit, sort); return this.restaurantESRepository.findAll(pageable); diff --git a/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/TestApplication.java b/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/TestApplication.java index ba9a21c39..2ce95e715 100644 --- a/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/TestApplication.java +++ b/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/TestApplication.java @@ -25,8 +25,7 @@ ElasticsearchContainer elasticsearchContainer() { @Bean @RestartScope MongoDBContainer mongoDBContainer() { - return new MongoDBContainer(DockerImageName.parse("mongo").withTag("6.0.12")) - .withSharding(); + return new MongoDBContainer(DockerImageName.parse("mongo").withTag("7.0.5")).withSharding(); } public static void main(String[] args) { diff --git a/docker-compose.yml b/docker-compose.yml index 47237db1f..ac4df1da5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -65,7 +65,7 @@ services: - /var/run/docker.sock:/var/run/docker.sock mongodb: - image: mongo:7.0.2 + image: mongo:7.0.5 ports: - "27017:27017" volumes: