{"id":15129857,"url":"https://github.com/elidaniel92/jetty-12-rest-api-sample","last_synced_at":"2026-01-19T04:32:49.009Z","repository":{"id":256325424,"uuid":"854938491","full_name":"elidaniel92/jetty-12-rest-api-sample","owner":"elidaniel92","description":"Simple REST API with Jetty 12","archived":false,"fork":false,"pushed_at":"2024-09-13T04:29:49.000Z","size":30,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-05T19:20:36.089Z","etag":null,"topics":["crud","crud-api","docker","docker-compose","jackson","java","jdbc","jetty","jetty-server","log4j2","maven","mysql","rest","rest-api","restful-api"],"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-10T02:50:40.000Z","updated_at":"2025-03-16T16:15:33.000Z","dependencies_parsed_at":"2024-09-10T06:16:11.869Z","dependency_job_id":"53dbc600-8a36-428c-9e2e-6a05d3e39fbe","html_url":"https://github.com/elidaniel92/jetty-12-rest-api-sample","commit_stats":null,"previous_names":["elidaniel92/jetty-12-rest-api-sample"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/elidaniel92/jetty-12-rest-api-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elidaniel92%2Fjetty-12-rest-api-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elidaniel92%2Fjetty-12-rest-api-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elidaniel92%2Fjetty-12-rest-api-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elidaniel92%2Fjetty-12-rest-api-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elidaniel92","download_url":"https://codeload.github.com/elidaniel92/jetty-12-rest-api-sample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elidaniel92%2Fjetty-12-rest-api-sample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28561841,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T03:31:16.861Z","status":"ssl_error","status_checked_at":"2026-01-19T03:31:15.069Z","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":["crud","crud-api","docker","docker-compose","jackson","java","jdbc","jetty","jetty-server","log4j2","maven","mysql","rest","rest-api","restful-api"],"created_at":"2024-09-26T02:21:53.185Z","updated_at":"2026-01-19T04:32:48.995Z","avatar_url":"https://github.com/elidaniel92.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jetty-12-rest-api-sample\n\nThis project serves as a boilerplate for building pure Jetty 12 (Servlet) 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- [**Jetty 12**](https://jetty.org/): Eclipse Jetty provides a highly scalable and memory-efficient web server and servlet container, supporting many protocols such as HTTP/3,2,1 and WebSocket.\n- [**Jackson**](https://github.com/FasterXML/jackson): The Java JSON library.\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 Jetty 12 (Servlet) 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\nClone the repository\n\n```\ngit clone https://github.com/elidaniel92/jetty-12-rest-api-sample.git\n```\n\nSwitch to the repo folder\n\n```\ncd jetty-12-rest-api-sample\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/jetty-12-rest-api-sample-1.0-SNAPSHOT.jar\n```\n#### With Maven\n```\nmvn clean compile exec:java\n```\n\n## Test:\n\nCRUD (create, read, update and delete).\n\n**POST**\n```\ncurl --location --request POST 'http://localhost:8080/api/products' \\\n--header 'Content-Type: application/json' \\\n--data '{\n    \"name\": \"Keyboard2\",\n    \"price\": 50,\n    \"quantityInStock\": 150\n}'\n```\n**GET**\n```\ncurl --location --request GET 'http://localhost:8080/api/products/2'\n```\n**PUT**\n```\ncurl --location --request PUT 'http://localhost:8080/api/products/2' \\\n--header 'Content-Type: application/json' \\\n--data '{\n    \"name\": \"Keyboard2\",\n    \"price\": 50,\n    \"quantityInStock\": 150\n}'\n```\n**DELETE**\n```\ncurl --location --request DELETE 'http://localhost:8080/api/products/2'\n```\n**GET LIST**\n```\ncurl --location --request GET 'http://localhost:8080/api/products'\n```\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%2Fjetty-12-rest-api-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felidaniel92%2Fjetty-12-rest-api-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felidaniel92%2Fjetty-12-rest-api-sample/lists"}