{"id":20057719,"url":"https://github.com/migmm/java-docker-sample","last_synced_at":"2026-04-14T19:31:25.166Z","repository":{"id":248440926,"uuid":"828384207","full_name":"migmm/java-docker-sample","owner":"migmm","description":"Simple JAVA with Springboot and MySQL application to show how to configure and run JAVA in Docker compose","archived":false,"fork":false,"pushed_at":"2024-07-15T14:30:55.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-06T20:55:22.079Z","etag":null,"topics":["docker","docker-compose","hibernate","java","jpa-persistence-applications","maven","mysql","springboot"],"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/migmm.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}},"created_at":"2024-07-14T01:32:13.000Z","updated_at":"2024-07-15T14:31:01.000Z","dependencies_parsed_at":"2025-03-02T09:41:53.012Z","dependency_job_id":"1193de47-6c35-4062-b57d-93d0b291247c","html_url":"https://github.com/migmm/java-docker-sample","commit_stats":null,"previous_names":["migmm/java-docker-sample"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/migmm/java-docker-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/migmm%2Fjava-docker-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/migmm%2Fjava-docker-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/migmm%2Fjava-docker-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/migmm%2Fjava-docker-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/migmm","download_url":"https://codeload.github.com/migmm/java-docker-sample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/migmm%2Fjava-docker-sample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31812968,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"ssl_error","status_checked_at":"2026-04-14T18:05:01.765Z","response_time":153,"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","hibernate","java","jpa-persistence-applications","maven","mysql","springboot"],"created_at":"2024-11-13T13:00:02.346Z","updated_at":"2026-04-14T19:31:25.134Z","avatar_url":"https://github.com/migmm.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Java Docker Sample Project\n\nThis project demonstrates how to configure and use Java with Docker and Docker Compose. It's a simple Spring Boot application that provides CRUD operations for a User entity.\n\n## Project Structure\n\n```\nsrc/main/java/com/usercrud/docker_sample/\n├── controller/\n│   └── UserController.java\n├── model/\n│   └── User.java\n├── repository/\n│   └── UserRepository.java\n├── service/\n│   └── UserService.java\n└── DockerSampleApplication.java\n```\n\n## Technologies Used\n\n- Java 21\n- Spring Boot 3.3.1\n- Spring Data JPA\n- MySQL\n- Maven\n- Docker\n- Docker Compose\n\n## Prerequisites\n\n- Java Development Kit (JDK) 21\n- Maven\n- Docker\n- Docker Compose\n\n## Setup and Running\n\n1. Clone the repository:\n   ```\n   git clone [your-repository-url]\n   cd [your-project-directory]\n   ```\n\n2. Build the project:\n   ```\n   mvn clean package\n   ```\n\n3. Build the Docker image:\n   ```\n   docker build -t java-docker-sample .\n   ```\n\n4. Run the application using Docker Compose:\n   ```\n   docker-compose up\n   ```\n\nThe application will be available at `http://localhost:8080`.\n\n## API Endpoints\n\n- GET `/users`: Retrieve all users\n- GET `/users/{id}`: Retrieve a specific user by ID\n- POST `/users`: Create a new user\n- PUT `/users/{id}`: Update an existing user\n- DELETE `/users/{id}`: Delete a user\n\n## Project Architecture\n\nThis project follows a layered architecture, specifically a 3-tier architecture pattern common in Spring Boot applications. Here's an overview of the architecture:\n\n1. Presentation Layer (Controllers)\n   - Location: `com.usercrud.docker_sample.controller`\n   - Purpose: Handles HTTP requests and defines API endpoints.\n   - Key Component: `UserController.java`\n\n2. Business Logic Layer (Services)\n   - Location: `com.usercrud.docker_sample.service`\n   - Purpose: Implements business logic and use cases.\n   - Key Component: `UserService.java`\n\n3. Data Access Layer (Repositories)\n   - Location: `com.usercrud.docker_sample.repository`\n   - Purpose: Manages data persistence and database operations.\n   - Key Component: `UserRepository.java`\n\nAdditional Components:\n\n4. Model Layer\n   - Location: `com.usercrud.docker_sample.model`\n   - Purpose: Defines data structures and entities.\n   - Key Component: `User.java`\n\n5. Configuration\n   - Key Components: `DockerSampleApplication.java`, `application.yml`\n   - Purpose: Configures the Spring Boot application and its components.\n\nThis architecture promotes:\n- Separation of concerns: Each layer has a specific responsibility.\n- Modularity: Components can be developed and tested independently.\n- Scalability: Layers can be scaled or modified separately as needed.\n- Maintainability: Clear structure makes the codebase easier to understand and maintain.\n\nThe project also leverages Spring Boot's dependency injection, which further enhances modularity and testability.\n\n## Configuration\n\nThe `application.yml` file contains the database configuration. Modify this file if you need to change any settings.\n\n### Hibernate Configuration\n\nBy default, Hibernate is set to update the database schema automatically. If you want to prevent Hibernate from modifying the database schema after the initial run, follow these steps:\n\n1. For the first run, use this configuration in your `application.yml`:\n\n   ```yaml\n   spring:\n     jpa:\n       hibernate:\n         ddl-auto: update\n   ```\n\n2. After the first run, change the configuration to:\n\n   ```yaml\n   spring:\n     jpa:\n       hibernate:\n         ddl-auto: none\n   ```\n\nThis will prevent Hibernate from modifying the database schema on subsequent runs.\n\n## Docker Configuration\n\nThe project includes a `Dockerfile` and a `docker-compose.yml` file for containerization:\n\n- `Dockerfile`: Defines how to build the Docker image for the Java application.\n- `docker-compose.yml`: Orchestrates the application and database services.\n\n### Docker Commands\n\nTo stop the Docker containers:\n```\ndocker-compose down\n```\n\nThis will stop the containers but preserve your data volumes.\n\nTo stop the containers and remove the containers, networks, and images created by `up`:\n```\ndocker-compose down --rmi all\n```\n\nTo stop the containers and remove all associated resources, including volumes (WARNING: This will delete all your data):\n```\ndocker-compose down -v\n```\nUse this command with caution as it will delete all data in your database.\n\nTo remove the Docker image:\n```\ndocker rmi java-docker-sample\n```\n\n## Testing with Postman\n\nA Postman collection file (`Java_Docker_Sample_Project.postman_collection.json`) is included in the project root. To use it:\n\n1. Open Postman\n2. Click on \"Import\" in the top left corner\n3. Drag and drop the JSON file or browse to select it\n4. The collection will be imported with pre-configured requests for all endpoints\n\n## Troubleshooting\n\nIf you encounter any issues while running the application, please check the following:\n\n1. Ensure all prerequisites are installed and properly configured.\n2. Verify that the MySQL server is running and accessible.\n3. Check if the required ports (8080 for the app, 3306 for MySQL) are available.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is open-sourced under the [MIT license](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmigmm%2Fjava-docker-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmigmm%2Fjava-docker-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmigmm%2Fjava-docker-sample/lists"}