This repo contains the code scaffolding to get started on a Spring Boot application.
- Compile the application in a jar. If you do not have
mvn
installed, you can use the maven wrapper in the /app/ directory,
cd app
./mvnw clean install
- Use the jar to start up the application,
cd app/target
java -jar <jar-name>
NOTE: Running the application locally requires a Postgres connection. You will need to configure the Postgres /app/src/resources/application.properties file. As an alternative to directly editing this file (it currently ingests environment variables to prevent credentials from being committed), it recommended you copy the .sample.env file into a new .env and configure the credentials there (the .env file is on the .gitignore),
cp .sample.env .env
These variables will need loaded into your current session. You can source
.env and export
them, i.e.,
source .env
export POSTGRES_HOST
export POSTGRES_PORT
# ...all the other variables Spring requires
However, this can be tedious. It is recommended, instead of manually compiling the jar and exporting the environment variables in your session, simply use the start script,
./scripts/start
This script will perform all the steps detailed above.
- Build the Docker image,
docker build -t spring-template:latest .
- Orchestrate the image with a Postgres container using the docker-compose.yml,
docker-compose up
- If you are on Windows, it is possible to spin up a Postgres container and expose it on port 5432 while a Postgres service is running locally on port 5432. This can leading to confusing errors. If you are getting authentication errors while trying to connect to the containerized database, see psql: FATAL: password authentication failed