This is a simple Spring Boot REST server that provides an API to create and read Journal Prompts.
These Journal Prompts can help you to write your own journal entries. they provide ideas for what to write about in your journal.
The journal prompts are stored in a backend database.
the database table(s) are created on the first executing of the application
using liquibase
.
The server currently has two database configuration profiles:
H2
MariaDb
These can be selected between by using the SPRING_PROFILES_ACTIVE
environment variable.
i.e:
SPRING_PROFILES_ACTIVE=mariadb
or
SPRING_PROFILES_ACTIVE=h2
if you choose to use H2 as the database a new file will be created called
KtJournalPrompts.h2
to store the prompt data.
To use MariaDb I have run a docker container using the following commands from a wsl terminal.
- Create a directory for the database to store persistent data and set its user so that we can execute mariadb without needing root access:
export DB_FILES_ROOT_DIR=/var/lib/mysql
sudo mkdir $DB_FILES_ROOT_DIR -p
sudo chown -R $USER:$USER $DB_FILES_ROOT_DIR $DB_FILES_ROOT_DIR
- Run the MariaDb docker container:
export DB_CONTAINER_NAME=mariadb-server
docker run -d --name $DB_CONTAINER_NAME -p 3306:3306 -v /var/lib/mysql:/var/lib/mysql -e "MYSQL_ROOT_PASSWORD=ktjpheaven" mariadb
once the database is running you can use the statements in mariadb_init_script.sql
to create the database and users.
I used this guide to set up MariaDb in a docker container.
to be able to execute the server we must first build the application. to do this we execute the following command from the root of the project.
mvn clean package
we can now execute the jar file from the target directory:
java -jar target/KtJournalPrompts.jar
or we can create a docker container and run the application inside the container:
docker build --tag=kt-journal-prompt:latest . --progress=plain
docker run -d --net prompts-net -e "SPRING_PROFILES_ACTIVE=mariadb" -p 8080:8080 kt-journal-prompt:latest
to run the server you can use one of the following methods:
- Run from within IntelliJ IDEA IDE.
- Run the server from the command line using the following command.
- Run the server inside a docker container.
Check OWASP vulnerabilities
(from Geeky Hacker) (for gradle)
- run
mvn clean org.owasp:dependency-check-maven:check
- run
mvn dependency:tree -DoutputFile=./dependency-tree.log -DoutputType=text
- run
mvn dependency:tree -DoutputFile=./dependency-tree.log.dot -DoutputType=dot
- then to convert the dot file to a png file use the following command:
dot -Tpng dependency-tree.log.dot -o dependency-tree.png