{"id":15129853,"url":"https://github.com/elidaniel92/java-17-mysql-docker-compose","last_synced_at":"2026-01-19T11:32:25.926Z","repository":{"id":256214325,"uuid":"854622892","full_name":"elidaniel92/java-17-mysql-docker-compose","owner":"elidaniel92","description":"This project serves as a boilerplate for building Java 17 applications using docker-compose to simplifies local development.","archived":false,"fork":false,"pushed_at":"2024-09-10T03:40:54.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T19:20:36.618Z","etag":null,"topics":["dirk","docker","docker-compose","java","java-17","jdbc","jsr330","log4j2","maven","mysql","slf4j"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elidaniel92.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-09-09T13:54:41.000Z","updated_at":"2024-09-10T03:40:57.000Z","dependencies_parsed_at":"2024-09-09T16:59:18.372Z","dependency_job_id":"0283dd6d-a0a9-4078-81ba-f4b0ae099e98","html_url":"https://github.com/elidaniel92/java-17-mysql-docker-compose","commit_stats":null,"previous_names":["elidaniel92/java-17-mysql-docker-compose"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/elidaniel92/java-17-mysql-docker-compose","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elidaniel92%2Fjava-17-mysql-docker-compose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elidaniel92%2Fjava-17-mysql-docker-compose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elidaniel92%2Fjava-17-mysql-docker-compose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elidaniel92%2Fjava-17-mysql-docker-compose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elidaniel92","download_url":"https://codeload.github.com/elidaniel92/java-17-mysql-docker-compose/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elidaniel92%2Fjava-17-mysql-docker-compose/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28566415,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T08:53:44.001Z","status":"ssl_error","status_checked_at":"2026-01-19T08:52:40.245Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["dirk","docker","docker-compose","java","java-17","jdbc","jsr330","log4j2","maven","mysql","slf4j"],"created_at":"2024-09-26T02:21:51.081Z","updated_at":"2026-01-19T11:32:25.910Z","avatar_url":"https://github.com/elidaniel92.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# java-17-mysql-docker-compose\n\n## **TL;DR**\n\nWindows - Powershell\n```\ndocker-compose build | docker-compose up\n```\nLinux - Bash\n```\ndocker-compose build \u0026\u0026 docker-compose up\n```\n\nThis project serves as a boilerplate for building Java 17 applications using the following technologies and tools:\n\n- [**Java 17**](https://www.oracle.com/br/java/technologies/downloads/): The latest long-term support version of Java, ensuring modern language features and improvements.\n- [**Maven**](https://maven.apache.org/): Used for project management and dependency management.\n- [**Docker Compose**](https://docs.docker.com/compose/): Simplifies local development by allowing you to run the entire application stack (including MySQL) within Docker containers.\n- [**Dirk**](https://github.com/hjohn/Dirk): A lightweight dependency injection library for managing object creation and dependencies.\n- [**SLF4J with Log4j2**](https://logging.apache.org/log4j/2.x/): Provides robust and flexible logging through the SLF4J API, using Log4j2 as the logging backend.\n- [**JDBC**](https://docs.oracle.com/javase/tutorial/jdbc/): Utilized for establishing a connection to relational databases and performing SQL operations.\n- [**MySQL Database**](https://www.mysql.com/): The database for storing and managing application data.\n\n\nThis setup is ideal for jump-starting a Java project with dependency injection, logging, and database connectivity, all contained in a local development environment via Docker Compose.\n\n# Getting started\n\n## Installation\n\n[Install Docker](https://www.docker.com/)\n\n[Install JDK 17](https://www.oracle.com/br/java/technologies/downloads/) (optional)\n\n[Install Maven](https://maven.apache.org/) (optional)\n\u003e **Tip:** you can run Maven commands without having Maven installed.\n```\n./mvnw foo\n```\n\n\nClone the repository\n\n```\ngit clone https://github.com/elidaniel92/java-17-mysql-docker-compose.git\n```\n\nSwitch to the repo folder\n\n```\ncd java-17-mysql-docker-compose\n```\n    \n### Install dependencies (optional)\n\n```\nmvn clean install\n```\n\n## Running the App with Docker Compose\n\nBuild the App and MySQL Container Image\n\n```\ndocker-compose build\n```\n\nStarted the container\n```\ndocker-compose up\n```\n\n## Running the Java Application locally and  MySQL Server in the container\n\n### Build the MySQL Container Image\n\nSince you cannot load an environment file using the `build command` command, go to the MySQL Dockerfile and uncomment the environment variables section.\n\n```\ndocker build -t db-img -f docker/Dockerfile.mysql .\n```\n### Start the MySQL Server Container\n```\ndocker run --name db-container -ip 3306:3306 db-img\n```\nAfter the message below, the server is ready for connections. You can close the terminal:\n```\n2024-09-07T22:48:15.362678Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.4.2'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.\n```\n### Setting the Java Application Environment Variable\n\nLoad the [local environment variables file (env/local.env)](env/local.env) in your terminal session.\n\nWindows - To load the env/local.env file in a PowerShell terminal session, use the command below:\n```\nGet-Content env/local.env | ForEach-Object { if ($_ -match '^(.*?)=(.*)$') { [System.Environment]::SetEnvironmentVariable($matches[1], $matches[2]) } }\n```\nLinux - To load the env/local.env file in a Bash terminal session, use the command below:\n```\nexport $(grep -v '^#' env/local.env | xargs)\n```\n\n### Running the app\n\n#### With .jar\n\nGenerete .jar\n```\nmvn clean package\n```\nRun .jar\n```\njava -jar target/java-17-mysql-docker-compose-1.0-SNAPSHOT.jar\n```\n#### With Maven\n```\nmvn clean compile exec:java\n```\n\n### Delete All Images and Containers\n\n```\ndocker rm -f db-container  \ndocker rmi db-img\ndocker rm -f store-system-app-1\ndocker rm -f store-system-db-1\ndocker rmi -f store-system-app\ndocker rmi -f store-system-db\n```\n\n# License\n\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felidaniel92%2Fjava-17-mysql-docker-compose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felidaniel92%2Fjava-17-mysql-docker-compose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felidaniel92%2Fjava-17-mysql-docker-compose/lists"}