{"id":30657249,"url":"https://github.com/cyberdevcorp/springboot-tuto-books-api","last_synced_at":"2026-04-11T13:03:03.891Z","repository":{"id":121228413,"uuid":"282967143","full_name":"cyberdevcorp/springboot-tuto-books-api","owner":"cyberdevcorp","description":"Springboot learning tutorial during my UDEV integration to CGI","archived":false,"fork":false,"pushed_at":"2024-08-26T17:58:44.000Z","size":66,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-31T11:18:47.733Z","etag":null,"topics":["docker","docker-compose","docker-container","h2-database","java","redis","spring-boot","springboot2","swagger-ui","swagger2"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cyberdevcorp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-07-27T17:24:06.000Z","updated_at":"2020-07-27T17:54:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"f290b3f6-2d28-4235-be59-d7038c90129e","html_url":"https://github.com/cyberdevcorp/springboot-tuto-books-api","commit_stats":null,"previous_names":["cyberdevcorp/springboot-tuto-books-api","mouhcine-flutter/springboot-tuto-books-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cyberdevcorp/springboot-tuto-books-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyberdevcorp%2Fspringboot-tuto-books-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyberdevcorp%2Fspringboot-tuto-books-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyberdevcorp%2Fspringboot-tuto-books-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyberdevcorp%2Fspringboot-tuto-books-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cyberdevcorp","download_url":"https://codeload.github.com/cyberdevcorp/springboot-tuto-books-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyberdevcorp%2Fspringboot-tuto-books-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31430009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T08:13:15.228Z","status":"ssl_error","status_checked_at":"2026-04-05T08:13:11.839Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","docker-container","h2-database","java","redis","spring-boot","springboot2","swagger-ui","swagger2"],"created_at":"2025-08-31T11:12:08.937Z","updated_at":"2026-04-05T08:34:15.976Z","avatar_url":"https://github.com/cyberdevcorp.png","language":"Java","readme":"# spingboot-tuto-books-api\n\nSping Boot 2 example BOOK API projet (list books, add books, find by author or title, ...) with docker, h2 db and redis cache\n\n - Use lombok\n - Build and run with open jdk 8, see \u003cjava.version\u003e maven property\n - REST controllers, see : package `com.example.demo.controller`\n - BookController use service, spring data with H2 mem DB (see `application.properties` file)\n - To changhe api port see application.properties\n\n\n## Build app\n\n - `mvn clean install -U` (or use maven wrapper : ./mvnw clean install or build and run with ./mvnw spring-boot:run)\n - See pom for unpack maven dependencies\n - Build Image : near Dockerfile launch `docker build --no-cache -t bookapp_image:1.0.0 .`\n \n## [Swagger](https://swagger.io/) IU\n\n - http://localhost:8080/api/swagger-ui.html\n \n## Run with docker\n\n - [For Windows hyper-v](https://docs.microsoft.com/fr-fr/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v) (Win 10 min)\n - `docker run -d --name appbook_micro1 -p 8080:8080 bookapp_image:1.0.0` (Detached (-d), without to see terminal log)\n \n## Other docker commands\n\n - `docker container ls --all` list containers (or `docker ps`)\n - `docker images` list images\n - `docker container stop appbook_micro1` stop container\n - `docker rm appbook_micro1` remove container\n - `docker rmi \u003cid-image\u003e` remove image\n - `docker network rm \u003cNETWORK\u003e` remove one or more networks\n \n# DB H2\n\n - In the same container than the app\n - See http://localhost:8080/api/h2-console/ (with JDBC URL : `jdbc:h2:mem:testdb`), to prevent H2 Console throwing a error webAllowOthers, must set `spring.h2.console.settings.web-allow-others` to true\n - See src/main/resources/db/runtime.sql for add data at start-up\n\n\n# REDIS cache\n\n - Only with !dev spring profile (dev mode use spring NoOpCacheManager)\n - With docker container\n - With [Jedis java client](https://github.com/xetorthio/jedis). Other option si Lettuce. See [here](https://redis.io/clients#java)\n\n\nSee [here](https://medium.com/@jaaq/making-docker-containers-talk-to-each-other-by-hostname-using-container-networking-94835a6f6a5b) to connect different docker containers. If we don't use Docker Compose :-(\n\n```\ndocker network list\ndocker network create myNetwork\ndocker network list\ndocker pull redis\ndocker run --name my-redis-container -d -p 6379:6379 --network myNetwork redis:latest\ndocker run -ti --rm --name appbook_micro1 -p 8080:8080 --network myNetwork bookapp_image:1.0.0\n```\n\n`docker network inspect myNetwork` to see containers connected to our network. See [here](https://docs.docker.com/network/) for more info.\n\n**Better to use docker compose :-). [See Docker compose section !](https://github.com/keuss/springboot-udev/blob/master/README.md#docker-compose)**\n\n - Connection to container with bash : `docker exec -it my-redis-container /bin/bash`\n - Test `redis-cli` (https://redis.io/topics/quickstart)\n\n\n## Test\n\nUse for instance [Postman](https://www.getpostman.com/downloads/) to test the REST services ... must add some books first.\n\nPOST http://localhost:8080/api/books\n\nwith payload :\n```\n{\n\t\"title\": \"LOTR 1\",\n\t\"author\": \"toto\"\n}\n```\n\nGET http://localhost:8080/api/books/\n\nGET http://localhost:8080/api/books/1\n\nGET http://localhost:8080/api/books/author/toto\n\n## Docker compose\n\n - `mvn clean install` (with 'myredis' host)\n - `docker-compose build` (don't forget to re-build image with this after update code !)\n - `docker-compose up`: start\n - `docker-compose down`: stop\n\n## Doc\n\n - Spring Boot: https://www.baeldung.com/spring-boot\n - [SpringBoot and Docker](https://spring.io/guides/gs/spring-boot-docker/) and [see A Better Dockerfile](https://spring.io/guides/topicals/spring-boot-docker/)\n - Docker compose networking : https://docs.docker.com/compose/networking/\n - Issue for communication between Spring Boot and Redis containers : https://stackoverflow.com/questions/51488311/docker-compose-spring-boot-redis-connection-issue/51518375, https://stackoverflow.com/questions/46135373/communication-between-spring-boot-and-redis-containers, https://stackoverflow.com/questions/51827759/spring-boot-redis-getting-connection-refused-exception-when-using-redis\n \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyberdevcorp%2Fspringboot-tuto-books-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyberdevcorp%2Fspringboot-tuto-books-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyberdevcorp%2Fspringboot-tuto-books-api/lists"}