https://github.com/timxor/java_api_setup
Spring Boot API template example.
https://github.com/timxor/java_api_setup
boot java spring spring-boot
Last synced: about 2 months ago
JSON representation
Spring Boot API template example.
- Host: GitHub
- URL: https://github.com/timxor/java_api_setup
- Owner: timxor
- License: mit
- Created: 2024-09-01T20:37:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2026-01-30T23:50:43.000Z (5 months ago)
- Last Synced: 2026-01-31T15:18:12.648Z (5 months ago)
- Topics: boot, java, spring, spring-boot
- Language: Java
- Homepage: https://github.com/timxor/java_api_setup
- Size: 78.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# java_api_setup
Spring Boot API template example.
Uses an in-memory H2 database, this ensures that your
tables are automatically created every time you restart the app.
# Quick Start
## Build the API
Clean project, update dependencies and rebuild everything:
```
mvn clean install -U
```
## Run the API
Run the API locally:
```
mvn spring-boot:run -Dspring-boot.run.profiles=local
# or
mvn spring-boot:run
```
## Query the API
Query the API locally:
```
curl -X GET "http://localhost:8080/hello?name=Tim"
```
Or query in browser [http://localhost:8080/hello?name=Tim](http://localhost:8080/hello?name=Tim)
## Open Swagger UI
Open Swagger UI API docs [http://localhost:8080/swagger-ui/index.html](http://localhost:8080/swagger-ui/index.html)
View the JSON OpenAPI spec file [http://localhost:8080/v3/api-docs](http://localhost:8080/v3/api-docs)
Download the YAML OpenAPI spec file [http://localhost:8080/v3/api-docs.yaml
](http://localhost:8080/v3/api-docs.yaml)
## Run Unit Tests
Run unit tests:
```
mvn test
```
Generate test coverage report:
```
mvn clean verify
```
View test coverage report at [file:///Users/timbo/code/java_api_setup/target/site/jacoco/index.html](file:///Users/timbo/code/java_api_setup/target/site/jacoco/index.html)
### Open H2 Console
H2 database Console:
Open H2 database console [http://localhost:8080/h2-console](http://localhost:8080/h2-console)
JDBC URL field: `jdbc:h2:mem:example_db`
username: `admin`
password: `admin`
## Java version
For this project we are using Java 21 version.
```
java=21.0.9-amzn
```
Install and set java version to v21:
```
sdk install java 21.0.9-amzn
sdk use java 21.0.9-amzn
sdk default java 21.0.9-amzn
java --version
# should look like this:
openjdk 21.0.9 2025-10-21 LTS
```
Make sure `$JAVA_HOME` is setup:
```
echo $JAVA_HOME
# should look something like this:
/Users/timbo/.sdkman/candidates/java/21.0.9-amzn
```
### Install Dev tools
Install helper dev tools dependencies:
```
brew install maven httpie jq
```
### Performance stats
Get performance state of a specific query:
```
curl -o /dev/null -s -w "DNS resolution: %{time_namelookup}s\nTCP connection: %{time_connect}s\nSSL handshake: %{time_appconnect}s\nServer processing: %{time_starttransfer}s\nTotal time: %{time_total}s\n" "http://localhost:8080/hello?name=Tim"
```